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
acf07e3e4fa0b203d0fb4bd2eb631275478e838b
320
class IntellijIdeaUltimateEap < Cask version '14-PublicPreview' sha256 '4995c98608506c02348b4dfc0507a6a791c9db0ee555916edfe2fef9aa2dc85a' url "http://download.jetbrains.com/idea/ideaIU-#{version}.dmg" homepage 'https://www.jetbrains.com/idea/index.html' license :unknown app 'IntelliJ IDEA 14 EAP.app' end
29.090909
75
0.7875
87bb8beb3437b229f0002369fe0164b293a57c9a
1,688
# frozen_string_literal: true require 'spec_helper' describe Mail::ReturnPathField do it "should allow you to specify a field" do rp = Mail::ReturnPathField.new('Return-Path: [email protected]') expect(rp.address).to eq '[email protected]' end it "should encode the addr_spec in <>" do rp = Mail::ReturnPathField.new('Return-Path: [email protected]') expect(rp.encoded).to eq "Return-Path: <[email protected]>\r\n" end it "should accept <>" do rp = Mail::ReturnPathField.new('<>') expect(rp.encoded).to eq "Return-Path: <>\r\n" end it "should set the return path" do mail = Mail.new do to "[email protected]" from "[email protected]" subject "Can't set the return-path" return_path "[email protected]" message_id "<[email protected]>" body "body" end expect(mail.return_path).to eq "[email protected]" end it "should set the return path" do mail = Mail.new do to "[email protected]" from "[email protected]" subject "Can't set the return-path" return_path "[email protected]" message_id "<[email protected]>" body "body" end encoded_mail = Mail.new(mail.encoded) expect(encoded_mail.return_path).to eq "[email protected]" end it "should wrap the return path addr_spec in <>" do mail = Mail.new do to "[email protected]" from "[email protected]" subject "Can't set the return-path" return_path "[email protected]" message_id "<[email protected]>" body "body" end expect(mail.encoded).to match(/<bounce@someemail\.com>/) end end
28.610169
74
0.655806
62468614729641f046312599f0b9fa65460efca0
2,267
require "spec_helper" describe Mongoid::Dirty do before do Person.delete_all end context "when fields are getting changed" do let(:person) do Person.create( :title => "MC", :ssn => "234-11-2533", :some_dynamic_field => 'blah' ) end before do person.title = "DJ" person.write_attribute(:ssn, "222-22-2222") person.some_dynamic_field = 'bloop' end it "marks the document as changed" do person.changed?.should == true end it "marks field changes" do person.changes.should == { "title" => [ "MC", "DJ" ], "ssn" => [ "234-11-2533", "222-22-2222" ], "some_dynamic_field" => [ "blah", "bloop" ] } end it "marks changed fields" do person.changed.should == [ "title", "ssn", "some_dynamic_field" ] end it "marks the field as changed" do person.title_changed?.should == true end it "stores previous field values" do person.title_was.should == "MC" end it "marks field changes" do person.title_change.should == [ "MC", "DJ" ] end it "allows reset of field changes" do person.reset_title! person.title.should == "MC" person.changed.should == [ "ssn", "some_dynamic_field" ] end context "after a save" do before do person.save! end it "clears changes" do person.changed?.should == false end it "stores previous changes" do person.previous_changes["title"].should == [ "MC", "DJ" ] person.previous_changes["ssn"].should == [ "234-11-2533", "222-22-2222" ] end end context "when the previous value is nil" do before do person.score = 100 person.reset_score! end it "removes the attribute from the document" do person.score.should be_nil end end end context "when associations are getting changed" do let(:person) do person = Person.create(:addresses => [ Address.new ]) end before do person.addresses = [ Address.new ] end it "should not set the association to nil when hitting the database" do person.setters.should_not == { "addresses" => nil } end end end
22.009709
81
0.58712
61121d120989953b9b3eae59fe709921c3c36b81
774
# -*- coding: utf-8 -*- # # frozen_string_literal: true describe Rouge::Lexers::Digdag do let(:subject) { Rouge::Lexers::Digdag.new } describe 'guessing' do include Support::Guessing it 'guesses by filename' do assert_guess :filename => 'foo.dig' end it 'guesses by mimetype' do assert_guess :mimetype => 'application/x-digdag' end end describe 'lexing' do include Support::Lexing it 'recognizes one line comment on last line even when not terminated by a new line (#360)' do assert_tokens_equal "+step1:\n echo> Hello!\n", ["Name.Attribute", "+step1"], ["Punctuation.Indicator", ":"], ["Text", "\n "], ["Literal.String", "echo> Hello!"], ["Text", "\n"] end end end
24.1875
98
0.605943
bf72217816c566e9b443f62c464bddf5d955977b
264
class CreateTranslations < ActiveRecord::Migration def self.up create_table :translations do |t| t.integer :shop_id t.string :to_lang t.boolean :paid t.timestamps end end def self.down drop_table :translations end end
16.5
50
0.670455
9149786519b53385940864e1d01c02fcf54e5375
558
# frozen_string_literal: true require 'three_scale_api/resources/default' module ThreeScaleApi module Resources # Application key resource wrapper for a application key entity received by the REST API class ApplicationKey < DefaultResource def account application.parent end def application client.resource end # @api public # Deletes key resource def delete read unless entity client.delete(entity['value']) if @manager.respond_to?(:delete) end end end end
21.461538
92
0.675627
3317881303d4c3d9852d4022a660c4fa100b808a
685
# frozen_string_literal: true # The following 2 values are used to tie the service to its IdentifierScheme. # make sure the :name if lowercase Rails.configuration.x.orcid.name = "orcid" # Credentials for the ORCID member API are pulled in from the Devise omniauth config # To disable this feature, simply set 'active' to false Rails.configuration.x.orcid.landing_page_url = Rails.configuration.x.dmproadmap.orcid_landing_page_url Rails.configuration.x.orcid.api_base_url = Rails.configuration.x.dmproadmap.orcid_api_base_url Rails.configuration.x.orcid.work_path = "%{id}/work/" Rails.configuration.x.orcid.callback_path = "work/%{put_code}" Rails.configuration.x.orcid.active = true
52.692308
102
0.807299
6ac662d7cc5bd89f81541e6c37170a272f728031
2,046
# Encoding: utf-8 # # This is auto-generated code, changes will be overwritten. # # Copyright:: Copyright 2018, Google Inc. All Rights Reserved. # License:: Licensed under the Apache License, Version 2.0. # # Code generated by AdsCommon library 1.0.1 on 2018-02-07 17:21:08. require 'ads_common/savon_service' require 'ad_manager_api/v201802/proposal_service_registry' module AdManagerApi; module V201802; module ProposalService class ProposalService < AdsCommon::SavonService def initialize(config, endpoint) namespace = 'https://www.google.com/apis/ads/publisher/v201802' super(config, endpoint, namespace, :v201802) end def create_proposals(*args, &block) return execute_action('create_proposals', args, &block) end def create_proposals_to_xml(*args) return get_soap_xml('create_proposals', args) end def get_marketplace_comments_by_statement(*args, &block) return execute_action('get_marketplace_comments_by_statement', args, &block) end def get_marketplace_comments_by_statement_to_xml(*args) return get_soap_xml('get_marketplace_comments_by_statement', args) end def get_proposals_by_statement(*args, &block) return execute_action('get_proposals_by_statement', args, &block) end def get_proposals_by_statement_to_xml(*args) return get_soap_xml('get_proposals_by_statement', args) end def perform_proposal_action(*args, &block) return execute_action('perform_proposal_action', args, &block) end def perform_proposal_action_to_xml(*args) return get_soap_xml('perform_proposal_action', args) end def update_proposals(*args, &block) return execute_action('update_proposals', args, &block) end def update_proposals_to_xml(*args) return get_soap_xml('update_proposals', args) end private def get_service_registry() return ProposalServiceRegistry end def get_module() return AdManagerApi::V201802::ProposalService end end end; end; end
28.816901
82
0.737537
e87115e93289c8d536994840bbfebc01560b38d2
1,749
module Puppet::Parser::Functions newfunction(:ensure_value_in_string, :type => :rvalue, :doc => <<-EOS Returns an string with appended values to the end if they were not present in original string. Prototype: ensure_value_in_string(string, array, separator = ',') Where string is the original string, array is array of additional values to append, separator is optional specifying delimiter and defaults to a comma. For example: Given the following statements: ensure_value_in_string('one,two', ['two', 'three']) The result will be as follows: 'one,two,three' You can specify you own separator as a third argument ensure_value_in_string('one,two', ['two', 'three'], ', ') results in 'one,two, three' EOS ) do |*arguments| # # This is to ensure that whenever we call this function from within # the Puppet manifest or alternatively form a template it will always # do the right thing ... # arguments = arguments.shift if arguments.first.is_a?(Array) raise Puppet::ParseError, "ensure_value_in_string(): Wrong number of arguments " + "given (#{arguments.size} for 2..3)" if arguments.size < 2 or arguments.size > 3 string = arguments.shift raise Puppet::ParseError, "ensure_value_in_string(): First argument is not string but #{string.class.to_s}" unless string.is_a?(String) adding = arguments.shift raise Puppet::ParseError, "ensure_value_in_string(): Second argument is not array but #{adding.class.to_s}" unless adding.is_a?(Array) separator = arguments.shift || ',' existing = string.split(separator.strip).map(&:strip) to_add = adding - existing ([ string.empty? ? nil : string ] + to_add).compact.join(separator) end end
31.8
139
0.705546
ab9cc23e9cc98ab2c6107a343ceee45b56cb527d
1,549
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## module MetasploitModule CachedSize = 53 include Msf::Payload::Single def initialize(info = {}) super(merge_info(info, 'Name' => 'OS X x64 say Shellcode', 'Description' => 'Say an arbitrary string outloud using Mac OS X text2speech', 'Author' => 'nemo <nemo[at]felinemenace.org>', 'License' => MSF_LICENSE, 'Platform' => 'osx', 'Arch' => ARCH_X64 )) # exec payload options register_options( [ OptString.new('TEXT', [ true, "The text to say", "Hello\!"]), ]) end # build the shellcode payload dynamically based on the user-provided CMD def generate say = (datastore['TEXT'] || '') << "\x00" call = "\xe8" + [say.length + 0xd].pack('V') payload = "\x48\x31\xC0" + # xor rax,rax "\xB8\x3B\x00\x00\x02" + # mov eax,0x200003b call + "/usr/bin/say\x00" + say + "\x48\x8B\x3C\x24" + # mov rdi,[rsp] "\x4C\x8D\x57\x0D" + # lea r10,[rdi+0xd] "\x48\x31\xD2" + # xor rdx,rdx "\x52" + # push rdx "\x41\x52" + # push r10 "\x57" + # push rdi "\x48\x89\xE6" + # mov rsi,rsp "\x0F\x05" # loadall286 end end
30.98
86
0.484829
7a1d12477cb56cbdb98e4d63bd1b8ad74f0769c4
29
# # Such a funny word.. #
7.25
22
0.482759
acd2f9179e1e54508e46447262c049f990175393
191
class ManageIQ::Providers::Amazon::NetworkManager::NetworkPort < ::NetworkPort def self.display_name(number = 1) n_('Network Port (Amazon)', 'Network Ports (Amazon)', number) end end
31.833333
78
0.727749
394208737075065d01311f71b217008dc0b42080
921
# Destroy all the records with user_id 0 # No new ones should be created once we switch to setting the user server-side TrainingModulesUsers.where(user_id: 0).destroy_all # These are all the records where we have a duplicate TrainingModulesUsers record for the same user+module combination. # We need delete the duplicates before adding a unique index. duplicates = TrainingModulesUsers.select(:user_id, :training_module_id).group(:user_id, :training_module_id).having("count(*) > 1").size # We want to keep either the earliest record that represents having completed the module, or just the earliest record # if none record module completion. duplicates.keys.each do |user_and_module| tmus = TrainingModulesUsers.where(user_id: user_and_module[0], training_module_id: user_and_module[1]).to_a keeper = tmus.detect { |tmu| tmu.completed_at.present? } keeper ||= tmus.first (tmus - [keeper]).each(&:destroy) end
54.176471
136
0.783931
1d45286f6d27cb4b1cdadc457d8213e16ab8c1e1
1,028
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. module AWS class RDS # Client class for Amazon Relational Database Service (RDS). class Client < Core::QueryClient API_VERSION = '2013-09-09' signature_version :Version4, 'rds' # @api private CACHEABLE_REQUESTS = Set[] end class Client::V20130515 < Client define_client_methods('2013-05-15') end class Client::V20130909 < Client define_client_methods('2013-09-09') end end end
23.906977
78
0.703307
acde526e86383f1fa06a4db86f4a31841a8e221b
1,262
# frozen_string_literal: true # Copyright 2021 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 # # https://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. # Auto-generated by gapic-generator-ruby. DO NOT EDIT! # [START dlp_v2_generated_DlpService_DeleteDeidentifyTemplate_sync] require "google/cloud/dlp/v2" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Dlp::V2::DlpService::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Dlp::V2::DeleteDeidentifyTemplateRequest.new # Call the delete_deidentify_template method. result = client.delete_deidentify_template request # The returned object is of type Google::Protobuf::Empty. p result # [END dlp_v2_generated_DlpService_DeleteDeidentifyTemplate_sync]
37.117647
74
0.786846
1d9a87dc1361da1df430cae32e20ecba915f4696
45
module Djangotorails VERSION = "0.0.1" end
11.25
20
0.711111
8714ac6d7a5af30b2560f480ada7329e5e6b2786
697
Pod::Spec.new do |s| s.name = "PokemonMasterKit" s.version = "0.0.2" s.summary = "Pokemon Utility Library" s.description = "Pokemon Utility Library written in Swift." s.homepage = "https://github.com/starhoshi/PokemonMasterKit" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "star__hoshi" => "[email protected]" } s.social_media_url = "https://twitter.com/star__hoshi" s.platform = :ios, "10.0" s.source = { :git => "https://github.com/starhoshi/PokemonMasterKit.git", :tag => s.version.to_s } s.source_files = "PokemonMasterKit/**/*.{swift}" end
46.466667
112
0.56528
3813771579e43d2ff8a486be49aa5039d5a70d84
13,480
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. # Devise will use the `secret_key_base` as its `secret_key` # by default. You can change it below and use your own secret key. config.secret_key = '123mt999' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. config.mailer_sender = '[email protected]' # Configure the class responsible to send e-mails. config.mailer = 'Devise::Mailer' # Configure the parent class responsible to send e-mails. # config.parent_mailer = 'ActionMailer::Base' # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. require 'devise/orm/active_record' # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is # just :email. You can configure it to use [:username, :subdomain], so for # authenticating a user, both parameters are required. Remember that those # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. # config.authentication_keys = [:email] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the # find_for_authentication method and considered in your model lookup. For instance, # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. # The same considerations mentioned for authentication_keys also apply to request_keys. # config.request_keys = [] # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [:email] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. config.strip_whitespace_keys = [:email] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the # given strategies, for example, `config.params_authenticatable = [:database]` will # enable it only for database (email + password) authentication. # config.params_authenticatable = true # Tell if authentication through HTTP Auth is enabled. False by default. # It can be set to an array that will enable http authentication only for the # given strategies, for example, `config.http_authenticatable = [:database]` will # enable it only for database authentication. The supported strategies are: # :database = Support basic authentication with authentication key + password # config.http_authenticatable = false # If 401 status code should be returned for AJAX requests. True by default. # config.http_authenticatable_on_xhr = true # The realm used in Http Basic Authentication. 'Application' by default. # config.http_authentication_realm = 'Application' # It will change confirmation, password recovery and other workflows # to behave the same regardless if the e-mail provided was right or wrong. # Does not affect registerable. # config.paranoid = true # By default Devise will store the user in session. You can skip storage for # particular strategies by setting this option. # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing skip: :sessions to `devise_for` in your config/routes.rb config.skip_session_storage = [:http_auth] # By default, Devise cleans up the CSRF token on authentication to # avoid CSRF token fixation attacks. This means that, when using AJAX # requests for sign in and sign up, you need to get a new CSRF token # from the server. You can disable this option at your own risk. # config.clean_up_csrf_token_on_authentication = true # When false, Devise will not attempt to reload routes on eager load. # This can reduce the time taken to boot the app but if your application # requires the Devise mappings to be loaded during boot time the application # won't boot properly. # config.reload_routes = true # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 11. If # using other algorithms, it sets how many times you want the password to be hashed. # # Limiting the stretches to just one in testing will increase the performance of # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use # a value less than 10 in other environments. Note that, for bcrypt (the default # algorithm), the cost increases exponentially with the number of stretches (e.g. # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). config.stretches = Rails.env.test? ? 1 : 11 # Set up a pepper to generate the hashed password. # config.pepper = '5fbf9eaea472a88a94c606b40aa03f1c8939ae1d9236f7a138dbee32d6306ddc69fa0b63e413dd7f046b032edd5e0bcd619947f7047ff8e837186780d16293de' # Send a notification to the original email when the user's email is changed. # config.send_email_changed_notification = false # Send a notification email when the user's password is changed. # config.send_password_change_notification = false # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without # confirming their account. For instance, if set to 2.days, the user will be # able to access the website for two days without confirming their account, # access will be blocked just in the third day. Default is 0.days, meaning # the user cannot access the website without confirming their account. # config.allow_unconfirmed_access_for = 2.days # A period that the user is allowed to confirm their account before their # token becomes invalid. For example, if set to 3.days, the user can confirm # their account within 3 days after the mail was sent, but on the fourth day # their account can't be confirmed with the token any more. # Default is nil, meaning there is no restriction on how long a user can take # before confirming their account. # config.confirm_within = 3.days # If true, requires any email changes to be confirmed (exactly the same way as # initial account confirmation) to be applied. Requires additional unconfirmed_email # db field (see migrations). Until confirmed, new email is stored in # unconfirmed_email column, and copied to email column on successful confirmation. config.reconfirmable = true # Defines which key will be used when confirming an account # config.confirmation_keys = [:email] # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks # Invalidates all the remember me tokens when the user signs out. config.expire_all_remember_me_on_sign_out = true # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false # Options to be passed to the created cookie. For instance, you can set # secure: true in order to force SSL only cookies. # config.rememberable_options = {} # ==> Configuration for :validatable # Range for password length. config.password_length = 6..128 # Email regex used to validate email formats. It simply asserts that # one (and only one) @ exists in the given string. This is mainly # to give user feedback and not to assert the e-mail validity. config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. # :none = No lock strategy. You should handle locking by yourself. # config.lock_strategy = :failed_attempts # Defines which key will be used when locking and unlocking an account # config.unlock_keys = [:email] # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email # :time = Re-enables login after a certain amount of time (see :unlock_in below) # :both = Enables both strategies # :none = No unlock strategy. You should handle unlocking by yourself. # config.unlock_strategy = :both # Number of authentication tries before locking an account if lock_strategy # is failed attempts. # config.maximum_attempts = 20 # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour # Warn on the last attempt before the account is locked. # config.last_attempt_warning = true # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account # config.reset_password_keys = [:email] # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to # change their passwords. config.reset_password_within = 6.hours # When set to false, does not sign a user in automatically after their password is # reset. Defaults to true, so a user is signed in automatically after a reset. # config.sign_in_after_reset_password = true # ==> Configuration for :encryptable # Allow you to use another hashing or encryption algorithm besides bcrypt (default). # You can use :sha1, :sha512 or algorithms from others authentication tools as # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 # for default behavior) and :restful_authentication_sha1 (then you should set # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). # # Require the `devise-encryptable` gem when using anything other than bcrypt # config.encryptor = :sha512 # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. config.scoped_views = true # Configure the default scope given to Warden. By default it's the first # devise role declared in your routes (usually :user). # config.default_scope = :user # Set this configuration to false if you want /users/sign_out to sign out # only the current scope. By default, Devise signs out all scopes. # config.sign_out_all_scopes = true # ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. # # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # # The "*/*" below is required to match Internet Explorer requests. # config.navigational_formats = ['*/*', :html] # The default HTTP method used to sign out a resource. Default is :delete. config.sign_out_via = :delete # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| # manager.intercept_401 = false # manager.default_strategies(scope: :user).unshift :some_external_strategy # end # ==> Mountable engine configurations # When using Devise inside an engine, let's call it `MyEngine`, and this engine # is mountable, there are some extra configurations to be taken into account. # The following options are available, assuming the engine is mounted as: # # mount MyEngine, at: '/my_engine' # # The router that invoked `devise_for`, in the example above, would be: # config.router_name = :my_engine # # When using OmniAuth, Devise cannot automatically set OmniAuth path, # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = '/my_engine/users/auth' end
48.489209
150
0.749258
218132bbdc1e58ba1dca3bc65f4d892fea1ab7ce
1,026
class I3status < Formula desc "Status bar for i3" homepage "https://i3wm.org/i3status" url "https://i3wm.org/i3status/i3status-2.11.tar.bz2" sha256 "98db7e730f0ce908eb656ac10d713ae6a885676621391d54f00b719752f18c5f" revision 3 head "https://github.com/i3/i3status.git" bottle do cellar :any sha256 "84e266369b0e59fbb5cb293c340a20773a81079ea80e484b5ecb5bbc6b03875b" => :high_sierra sha256 "8044ac2d7c39945c3ca02cb943e485333351080c5f12c421f7d87ea0c877bc74" => :sierra sha256 "af7fa1f5913eaaa9f824fa5f11e50523d474473d034d91712b9cf18bb1a56b5f" => :el_capitan end depends_on :x11 depends_on "yajl" depends_on "confuse" depends_on "pulseaudio" depends_on "asciidoc" => :build depends_on "i3" def install system "make", "A2X_FLAGS=--no-xmllint" system "make", "install", "PREFIX=#{prefix}" end test do result = shell_output("#{bin}/i3status -v") result.force_encoding("UTF-8") if result.respond_to?(:force_encoding) assert_match version.to_s, result end end
30.176471
93
0.749513
1150c96cd00a1dfd836ef841ddacef9afc64924a
10,609
#!/usr/bin/env ruby require 'gtk2' require 'resolv' require './lib/queue_tab.rb' require './lib/transfer_queue.rb' require './lib/host.rb' require './lib/imux_config.rb' class MultiplexityGTK def initialize @host_objects = [] @queue_objects = [] @tabs = [] build_essentials @window.show_all Gtk.main end def build_essentials @window = Gtk::Window.new("Multiplexity") @window.set_default_size(1300,700) @window.signal_connect("destroy") { Gtk.main_quit } build_hosts add_host(Localhost.new()) build_queues @tabbed = Gtk::Notebook.new @tabbed.set_size_request(1000,500) vbox = Gtk::VBox.new(false, 0) vbox.set_size_request(300,400) settings = Gtk::Button.new("Settings") route_help = Gtk::Button.new("Routing help") vbox.pack_start @hosts, true, true, 0 vbox.pack_start @queues, true, true, 0 vbox.pack_start settings, false, false, 0 vbox.pack_start route_help, false, false, 0 hbox = Gtk::HBox.new(false, 0) hbox.pack_start vbox, false, false, 0 hbox.pack_start @tabbed, true, true, 0 @window.add(hbox) #attach_queue_tab end def build_hosts @hosts = Gtk::VBox.new(false, 5) @hosts_top_hbox = Gtk::HBox.new(false, 0) @hosts_label = Gtk::Label.new @hosts_label.set_markup("<span size=\"x-large\" weight=\"bold\">Hosts</span>") @hosts_filler = Gtk::HBox.new(true, 0) @add_host = Gtk::Button.new("+") @add_host.signal_connect("clicked"){ ask_for_a_host } @hosts_tree = Gtk::ListStore.new(String, String) @hosts_view = Gtk::TreeView.new(@hosts_tree) columns = ["","Hostname"] columns.each_with_index do |column, i| renderer = Gtk::CellRendererText.new colum = Gtk::TreeViewColumn.new(column, renderer, :text => i) @hosts_view.append_column(colum) end @rclick_host_menu = Gtk::Menu.new @host_connect_item = Gtk::MenuItem.new("Connect") @host_connect_item.signal_connect("activate") { puts "connect" } @host_disconnect_item = Gtk::MenuItem.new("Disconnect") @host_disconnect_item.signal_connect("activate") { puts "disconnect" } @host_remove_item = Gtk::MenuItem.new("Remove") @host_remove_item.signal_connect("activate") { puts "remove" } @rclick_host_menu.append(@host_connect_item) @rclick_host_menu.append(@host_disconnect_item) @rclick_host_menu.append(@host_remove_item) @rclick_host_menu.show_all @hosts_view.signal_connect("button_press_event") do |widget, event| @rclick_host_menu.popup(nil, nil, event.button, event.time) if event.kind_of? Gdk::EventButton and event.button == 3 end @scrolled_hosts = Gtk::ScrolledWindow.new @scrolled_hosts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @hosts_top_hbox.pack_start @hosts_label, false, false, 0 @hosts_top_hbox.pack_start @hosts_filler, true, true, 0 @hosts_top_hbox.pack_start @add_host, false, false, 0 @scrolled_hosts.add(@hosts_view) @hosts.pack_start @hosts_top_hbox, false, false, 0 @hosts.pack_start @scrolled_hosts, true, true, 0 end def add_host(host) @host_objects << host row = @hosts_tree.append() row[0] = "" row[1] = host.hostname end def remove_host(host) @hosts.delete(host) # remove from view end def build_queues @queues = Gtk::VBox.new(false, 5) @queues_top_hbox = Gtk::HBox.new(false, 0) @queues_label = Gtk::Label.new @queues_label.set_markup("<span size=\"x-large\" weight=\"bold\">Queues</span>") @add_queue = Gtk::Button.new("+") @add_queue.signal_connect("clicked"){ build_a_queue } @queue_filler = Gtk::HBox.new(true, 0) @queues_tree = Gtk::ListStore.new(String, String, String) @queues_view = Gtk::TreeView.new(@queues_tree) @columns = ["","Client","Server"] @columns.each_with_index do |column, i| renderer = Gtk::CellRendererText.new colum = Gtk::TreeViewColumn.new(column, renderer, :text => i) colum.resizable = true if i > 0 @queues_view.append_column(colum) end @scrolled_queues = Gtk::ScrolledWindow.new @scrolled_queues.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @queues_top_hbox.pack_start @queues_label, false, false, 0 @queues_top_hbox.pack_start @queue_filler, true, true, 0 @queues_top_hbox.pack_start @add_queue, false, false, 0 @scrolled_queues.add(@queues_view) @queues.pack_start @queues_top_hbox, false, false, 0 @queues.pack_start @scrolled_queues, true, true, 0 end def add_queue(queue) @queue_objects << queue row = @queues_tree.append() row[0] = queue[:state] row[1] = queue[:hostname] end def attach_queue_tab(client, server, transfer_queue) tab = QueueTab.new(client, server, transfer_queue) @tabs << tab page = tab.queue_tab page.show_all tab.update_client_files tab.update_server_files @tabbed.append_page(page, Gtk::Label.new("#{client.hostname} <-> #{server.hostname}")) row = @queues_tree.append() row[0] = "" row[1] = client.hostname row[2] = server.hostname end def ask_for_a_host add_host_box = Gtk::Dialog.new("New Host") add_host_box.signal_connect('response') { add_host_box.destroy } vbox = Gtk::VBox.new(false, 0) hostname_port_line = Gtk::HBox.new(false, 5) hostname_label = Gtk::Label.new("Hostname: ") hostname_entry = Gtk::Entry.new() port_label = Gtk::Label.new("Port: ") port_entry = Gtk::Entry.new() port_entry.width_chars = 5 port_entry.set_text("8000") pass_connect_line = Gtk::HBox.new(false, 5) password_label = Gtk::Label.new("Password: ") password_entry = Gtk::Entry.new() connect_button = Gtk::Button.new("Connect") hostname_port_line.pack_start hostname_label, false, false, 0 hostname_port_line.pack_start hostname_entry, true, true, 0 hostname_port_line.pack_start port_label, false, false, 0 hostname_port_line.pack_start port_entry, false, false, 0 pass_connect_line.pack_start password_label, false, false, 0 pass_connect_line.pack_start password_entry, false, false, 0 pass_connect_line.pack_start connect_button, true, true, 0 connect_button.signal_connect("clicked") { error = attempt_to_connect(hostname_entry.text, port_entry.text, password_entry.text) if error != nil dialog = Gtk::MessageDialog.new($main_application_window, Gtk::Dialog::DESTROY_WITH_PARENT, Gtk::MessageDialog::QUESTION, Gtk::MessageDialog::BUTTONS_CLOSE, "Could not connect to host: #{error}") dialog.run dialog.destroy else add_host_box.destroy end } vbox.pack_start hostname_port_line, false, false, 5 vbox.pack_start pass_connect_line, false, false, 5 add_host_box.vbox.add(vbox) add_host_box.show_all end def build_ip_config_line line = Gtk::HBox.new(false, 5) ip_entry = Gtk::Entry.new ip_entry.width_chars=3 ip_label = Gtk::Label.new("IPs") bound = Gtk::CheckButton.new("Bound") bind_ip = Gtk::Entry.new bound.signal_connect("clicked") { bind_ip.set_sensitive !bind_ip.sensitive? } bind_ip.set_sensitive false line.pack_start ip_entry, false, false, 0 line.pack_start ip_label, false, false, 0 line.pack_start bound, false, false, 0 line.pack_start bind_ip, true, true, 0 return line end def build_a_queue add_queue_box = Gtk::Dialog.new("New queue") add_queue_box.signal_connect('response') { add_queue_box.destroy } vbox = Gtk::VBox.new(false, 5) host_section = Gtk::VBox.new(false, 5) host_selection_label = Gtk::Label.new() host_selection_label.set_markup("<span size=\"x-large\" weight=\"bold\">Select hosts</span>") host_selection_line = Gtk::HBox.new(false, 5) client_label = Gtk::Label.new("Client: ") client_selection = Gtk::ComboBox.new() @host_objects.each do |host| client_selection.append_text host.hostname end server_label = Gtk::Label.new("Server: ") server_selection = Gtk::ComboBox.new() @host_objects.each do |host| server_selection.append_text host.hostname end host_selection_line.pack_start client_label, false, false, 0 host_selection_line.pack_start client_selection, true, true, 0 host_selection_line.pack_start server_label, false, false, 0 host_selection_line.pack_start server_selection, true, true, 0 host_section.pack_start host_selection_label, false, false, 0 host_section.pack_start host_selection_line, false, false, 0 imux_section = Gtk::VBox.new(false, 0) imux_section_label = Gtk::Label.new() imux_section_label.set_markup("<span size=\"x-large\" weight=\"bold\">IMUX Settings</span>") bound_ip_box = Gtk::VBox.new(false, 0) add_ip_button = Gtk::Button.new("Add another IP") add_ip_button.signal_connect("clicked"){ bound_ip_box.pack_start build_ip_config_line.show_all, false, false, 0 } imux_section.pack_start imux_section_label, false, false, 0 imux_section.pack_start bound_ip_box, true, true, 0 imux_section.pack_start add_ip_button, false, false, 0 create_button = Gtk::Button.new("Create queue") create_button.signal_connect("clicked"){ client = nil server = nil transfer_queue = nil @host_objects.each do |host| client = host if host.hostname == client_selection.active_text server = host if host.hostname == server_selection.active_text end if server == nil || client == nil dialog = Gtk::MessageDialog.new($main_application_window, Gtk::Dialog::DESTROY_WITH_PARENT, Gtk::MessageDialog::QUESTION, Gtk::MessageDialog::BUTTONS_CLOSE, "Please select both a server and a client.") dialog.run dialog.destroy break end imux_config = IMUXConfig.new() # ok so actually parse the input and make this object transfer_queue = TransferQueue.new(client, server, imux_config) Thread.new{ loop{ puts transfer_queue.message_queue.pop } } if !transfer_queue.opened dialog = Gtk::MessageDialog.new($main_application_window, Gtk::Dialog::DESTROY_WITH_PARENT, Gtk::MessageDialog::QUESTION, Gtk::MessageDialog::BUTTONS_CLOSE, "The transfer queue could not be built correctly. See the messages box for more information.") dialog.run dialog.destroy break end attach_queue_tab(client, server, transfer_queue) add_queue_box.destroy } vbox.pack_start host_section, false, false, 0 vbox.pack_start imux_section, false, false, 0 vbox.pack_start create_button, false, false, 0 add_queue_box.vbox.add(vbox) add_queue_box.show_all end def attempt_to_connect(hostname, port, password) begin port = port.to_i rescue return "port is not an integer" end host = Host.new(hostname, port, password) error = host.handshake return error if error != nil add_host(host) return nil end end MultiplexityGTK.new
32.743827
119
0.724008
abb443a35d24d7db03359978943aea339cbf3b32
95
module Unit class Parsec < Linear @normalization_factor = 3.08567758e19 end end
10.555556
41
0.684211
f8e9e6d06ba0b0ecc0038c0b17fea6999d6f0a13
206
# This migration comes from ddr_models (originally 20150130134416) class AddUserKeyToEvents < ActiveRecord::Migration def change change_table :events do |t| t.string :user_key end end end
22.888889
66
0.747573
b92c95f5a6b84dc0dce5d2263be933f9d4b841a6
1,059
# Copyright 2016 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 # # https://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 "helper" describe Google::Cloud::Logging::Project, :shared_async_writer, :mock_logging do it "returns the same async writer object" do async1 = logging.shared_async_writer async1.must_be_kind_of Google::Cloud::Logging::AsyncWriter async1.logging.must_be_same_as logging async1.max_queue_size.must_equal \ Google::Cloud::Logging::AsyncWriter::DEFAULT_MAX_QUEUE_SIZE async2 = logging.shared_async_writer async2.must_be_same_as async1 end end
37.821429
80
0.770538
e2d51ead0b28213c011b1d451e8ec9e7b7c7386d
3,805
require 'spec_helper' describe System do include CfConnectionHelper context 'without a user logged in' do before(:all) do VCR.use_cassette("models/no_logged/client", :record => :new_episodes) do cf_client = cloudfoundry_client(CloudFoundry::Client::DEFAULT_TARGET) @system = System.new(cf_client) end end use_vcr_cassette "models/no_logged/system", :record => :new_episodes it 'returns basic account info' do account_info = @system.find_account_info() account_info.should have_key :name account_info.should have_key :build account_info.should have_key :support account_info.should have_key :version account_info.should have_key :description account_info.should have_key :allow_debug end it 'returns an empty list of frameworks' do frameworks = @system.find_all_frameworks() frameworks.should be_empty end it 'returns an empty list of runtimes' do runtimes = @system.find_all_runtimes() runtimes.should be_empty end it 'raises an AuthError exception when looking for all system services' do expect { system_services = @system.find_all_system_services() }.to raise_exception(CloudFoundry::Client::Exception::AuthError) end it 'returns no available memory' do available_memory = @system.find_available_memory() available_memory.should be_a_kind_of(Integer) available_memory.should eql(0) end end context 'with a user logged in' do before(:all) do VCR.use_cassette("models/logged/client", :record => :new_episodes) do cf_client = cloudfoundry_client_user_logged(CloudFoundry::Client::DEFAULT_TARGET) @system = System.new(cf_client) end end use_vcr_cassette "models/logged/system", :record => :new_episodes it 'returns user account info' do account_info = @system.find_account_info() account_info.should have_key :name account_info.should have_key :build account_info.should have_key :support account_info.should have_key :version account_info.should have_key :description account_info.should have_key :allow_debug account_info.should have_key :user account_info.should have_key :limits account_info.should have_key :usage account_info.should have_key :frameworks end it 'returns a proper list of frameworks' do frameworks = @system.find_all_frameworks() frameworks.should have_at_least(1).items framework_info = frameworks.first[1] framework_info.should have_key :name framework_info.should have_key :runtimes framework_info.should have_key :appservers framework_info.should have_key :detection end it 'returns a proper list of runtimes' do runtimes = @system.find_all_runtimes() runtimes.should have_at_least(1).items runtime_info = runtimes.first[1] runtime_info.should have_key :name runtime_info.should have_key :version runtime_info.should have_key :description end it 'returns a proper list of system services' do system_services = @system.find_all_system_services() system_services.should have_at_least(1).items system_service_info = system_services.first[1].values[0].first[1] system_service_info.should have_key :id system_service_info.should have_key :vendor system_service_info.should have_key :version system_service_info.should have_key :tiers system_service_info.should have_key :type system_service_info.should have_key :description end it 'returns the user account available memory' do available_memory = @system.find_available_memory() available_memory.should be_a_kind_of(Integer) end end end
34.908257
89
0.722733
1a095795a1b6b8a0e34038d6413ac997d97cf1ca
1,397
class Dxflib < Formula desc "C++ library for parsing DXF files" homepage "https://www.ribbonsoft.com/en/what-is-dxflib" url "https://www.ribbonsoft.com/archives/dxflib/dxflib-2.5.0.0-1.src.tar.gz" sha256 "20ad9991eec6b0f7a3cc7c500c044481a32110cdc01b65efa7b20d5ff9caefa9" livecheck do url "https://www.ribbonsoft.com/en/dxflib-downloads" regex(/href=.*?dxflib[._-]v?(\d+(?:\.\d+)+)-src\.t/i) end bottle do rebuild 2 sha256 cellar: :any_skip_relocation, catalina: "70b4e8b65b8a1090eb19080c1ec7675ec58aaef4c573ac2af89f2fe985e23d7e" sha256 cellar: :any_skip_relocation, mojave: "1b9e667aa5bb30e050f41370afbbfaa91a563ab015a4ab4930c7dbb99fccc956" sha256 cellar: :any_skip_relocation, high_sierra: "fb790fe1b9357907e77f50650ed0d696e855c311320d726472ac511297994573" sha256 cellar: :any_skip_relocation, sierra: "db45aa2b00f82b996370eaf1321e0cce79fc3868c42a9524e10adce478139bc2" sha256 cellar: :any_skip_relocation, el_capitan: "aff6c3f5e5bca552c5962e8ef5c43d1dd5fb0630d091e206a164e99ed8b70637" sha256 cellar: :any_skip_relocation, yosemite: "e883aa60c9baab1198671db178c0723e4331ed9fb65ad4d87ba72ca921d7d0b4" sha256 cellar: :any_skip_relocation, mavericks: "0e591fba7cac298bf4afbb4d7f9895c10865998c6ae64ad4db31c7a33c3377cc" end def install system "./configure", "--prefix=#{prefix}" system "make", "install" end end
49.892857
120
0.786686
eda4c759f5a75e50750056019d09d0b27968ebbd
1,679
class MenusController < ApplicationController before_action :signed_in_user, only: [:index, :create] before_action :correct_user, only: :destroy def index @menus = Menu.paginate(page: params[:page]) @menu = current_user.menus.build @levels = Level.all @categories = Category.all end def create @levels = Level.all @categories = Category.all @menu = current_user.menus.new(menu_params) do |t| uploaded_io = params[:menu][:image] if params[:menu][:image] File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file| file.write(uploaded_io.read) t.filename = uploaded_io.original_filename t.mime_type = uploaded_io.content_type end end end if @menu.save flash[:success] = "Recipe has been created!" redirect_to root_url else render 'menus/index' end end def show @menu = Menu.find(params[:id]) @level = Level.find(@menu.level_id) @category = Category.find(@menu.category_id) @user = User.find(@menu.user_id) end def destroy @menu.destroy redirect_to current_user flash[:success] = "Recipe has been deleted." end private def menu_params params.require(:menu).permit(:title, :ingredient, :description, :preparation, :serve, :cooking_time, :level_id, :category_id) end # Before filters def signed_in_user unless signed_in? store_location redirect_to signin_url, danger: "Please sign in first." end end def correct_user @menu = current_user.menus.find_by(id: params[:id]) redirect_to root_url if @menu.nil? end end
23.985714
129
0.664681
ab81fbd0a6bc47cb7558ba26256fd903c7c25f9e
735
cask 'blitz' do version '0.9.20' sha256 '0f36b95bec82ea44ec1956731f8bcc9c0a66eafa92b13f97989069548b95786e' url 'https://dl.blitz.gg/download/mac' appcast 'https://www.corecode.io/cgi-bin/check_urls/check_url_filename.cgi?url=https://dl.blitz.gg/download/mac' name 'Blitz' homepage 'https://blitz.gg/' auto_updates true app 'Blitz.app' uninstall quit: 'com.blitz.app' zap trash: [ '~/Library/Application Support/Blitz', '~/Library/Caches/com.blitz.app.ShipIt', '~/Library/Cookies/com.blitz.app.binarycookies', '~/Library/Preferences/com.blitz.app.plist', '~/Library/Saved Application State/com.blitz.app.savedState', ] end
30.625
114
0.655782
6a8c26605cd75b0817b818c9b755fb886df51d60
105
# frozen_string_literal: true require 'test_helper' class ContactHelperTest < ActionView::TestCase end
15
46
0.819048
08b09b9f32dfcbaf6ced1126c3a3531d926f69f4
181
module Blacklight::Solr::Document::RisFields extend ActiveSupport::Concern module ClassMethods def ris_field_mappings @ris_field_mappings ||= {} end end end
13.923077
44
0.712707
b9272a1ce04226eb9741d1f6ff0d0ee2a556b551
132
require 'test_helper' class ShareControllerTest < ActionController::TestCase # test "the truth" do # assert true # end end
16.5
54
0.727273
6164c09c987b03a3dbfc68b2a3399246a393485b
7,741
# frozen_string_literal: true require_relative '../spec_helper' describe Dyndnsd::Daemon do include Rack::Test::Methods def app Dyndnsd.logger = Logger.new($stdout) Dyndnsd.logger.level = Logger::UNKNOWN config = { 'domain' => 'example.org', 'users' => { 'test' => { 'password' => 'secret', 'hosts' => ['foo.example.org', 'bar.example.org'] } } } db = Dyndnsd::DummyDatabase.new({}) updater = Dyndnsd::Updater::Dummy.new daemon = Dyndnsd::Daemon.new(config, db, updater) app = Rack::Auth::Basic.new(daemon, 'DynDNS', &daemon.method(:authorized?)) Dyndnsd::Responder::DynDNSStyle.new(app) end it 'requires authentication' do get '/' expect(last_response.status).to eq(401) expect(last_response.body).to eq('badauth') end it 'requires configured correct credentials' do authorize 'test', 'wrongsecret' get '/' expect(last_response.status).to eq(401) expect(last_response.body).to eq('badauth') end it 'only supports GET requests' do authorize 'test', 'secret' post '/nic/update' expect(last_response.status).to eq(405) end it 'provides only the /nic/update URL' do authorize 'test', 'secret' get '/other/url' expect(last_response.status).to eq(404) end it 'requires the hostname query parameter' do authorize 'test', 'secret' get '/nic/update' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') end it 'supports multiple hostnames in request' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org,bar.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq("good 1.2.3.4\ngood 1.2.3.4") get '/nic/update?hostname=foo.example.org,bar.example.org&myip=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq("good 2001:db8::1\ngood 2001:db8::1") end it 'rejects request if one hostname is invalid' do authorize 'test', 'secret' get '/nic/update?hostname=test' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') get '/nic/update?hostname=test.example.com' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') get '/nic/update?hostname=test.example.org.me' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') get '/nic/update?hostname=foo.test.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') get '/nic/update?hostname=in%20valid.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') get '/nic/update?hostname=valid.example.org,in.valid.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('notfqdn') end it 'rejects request if user does not own one hostname' do authorize 'test', 'secret' get '/nic/update?hostname=notmyhost.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('nohost') get '/nic/update?hostname=foo.example.org,notmyhost.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('nohost') end it 'updates a host on IP change' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok get '/nic/update?hostname=foo.example.org&myip=1.2.3.40' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.40') get '/nic/update?hostname=foo.example.org&myip=2001:db8::1' expect(last_response).to be_ok get '/nic/update?hostname=foo.example.org&myip=2001:db8::10' expect(last_response).to be_ok expect(last_response.body).to eq('good 2001:db8::10') end it 'returns IP no change' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq('nochg 1.2.3.4') get '/nic/update?hostname=foo.example.org&myip=2001:db8::1' expect(last_response).to be_ok get '/nic/update?hostname=foo.example.org&myip=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq('nochg 2001:db8::1') end it 'outputs IP status per hostname' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.4') get '/nic/update?hostname=foo.example.org,bar.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq("nochg 1.2.3.4\ngood 1.2.3.4") get '/nic/update?hostname=foo.example.org&myip=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq('good 2001:db8::1') get '/nic/update?hostname=foo.example.org,bar.example.org&myip=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq("nochg 2001:db8::1\ngood 2001:db8::1") end it 'offlines a host' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.4') get '/nic/update?hostname=foo.example.org&offline=YES' expect(last_response).to be_ok expect(last_response.body).to eq('good ') get '/nic/update?hostname=foo.example.org&offline=YES' expect(last_response).to be_ok expect(last_response.body).to eq('nochg ') get '/nic/update?hostname=foo.example.org&myip=1.2.3.4' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.4') get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&offline=YES' expect(last_response).to be_ok expect(last_response.body).to eq('good ') get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&offline=YES' expect(last_response).to be_ok expect(last_response.body).to eq('nochg ') end it 'uses clients remote IP address if myip not specified' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org' expect(last_response).to be_ok expect(last_response.body).to eq('good 127.0.0.1') end it 'uses clients remote IP address from X-Real-IP header if behind proxy' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org', '', 'HTTP_X_REAL_IP' => '10.0.0.1' expect(last_response).to be_ok expect(last_response.body).to eq('good 10.0.0.1') get '/nic/update?hostname=foo.example.org', '', 'HTTP_X_REAL_IP' => '2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq('good 2001:db8::1') end it 'supports an IPv4 and an IPv6 address in one request' do authorize 'test', 'secret' get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&myip6=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.4 2001:db8::1') get '/nic/update?hostname=foo.example.org&myip=BROKENIP&myip6=2001:db8::1' expect(last_response).to be_ok expect(last_response.body).to eq('nohost') get '/nic/update?hostname=foo.example.org&myip=1.2.3.4&myip6=BROKENIP' expect(last_response).to be_ok expect(last_response.body).to eq('nohost') get '/nic/update?hostname=foo.example.org&myip6=2001:db8::10' expect(last_response).to be_ok expect(last_response.body).to eq('nohost') get '/nic/update?hostname=foo.example.org&myip=1.2.3.40' expect(last_response).to be_ok expect(last_response.body).to eq('good 1.2.3.40') end end
32.120332
85
0.686345
f8747a195ffd4b3d16c1a195aa77990e6f589b19
953
require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/try' class BankingData::AustrianBank < BankingData::Bank extend ActiveModel::Naming include ActiveModel::Conversion include ActiveModel::AttributeMethods LOCALE = :at attr_accessor :bic, :blz class << self delegate :where, :only, to: :query delegate :map, :each, to: :all def all @@all ||= get_all end def get_all banks = [] SmarterCSV.process(file, opts).each do |line| blz = line[:bankleitzahl].to_s bic = line[:'swift_code'] if blz && bic banks << new(bic: bic, blz: blz) end end banks.uniq end private def file File.dirname(__FILE__) + '/../../data/SEPA-ZV-VZ_gesamt_de_1615904610976.csv' end def opts { col_sep: ';', file_encoding: 'iso-8859-1' } end end end
19.44898
62
0.587618
33ca2b9e335724ea641bada87c19e9a2f14e3534
650
class Page < ActiveRecord::Base serialize :data, Hash validates :title, presence: true, uniqueness: true validates :content, presence: true validate :valid_liquid_syntax attr_accessible :title, :content, :data extend FriendlyId friendly_id :title, use: :slugged private def valid_liquid_syntax Liquid::Template.parse(content) rescue Liquid::SyntaxError => e errors.add( :content, I18n.t( 'activerecord.errors.models.page_module.attributes.content.liquid_syntax_invalid', message: e.message ) ) end def should_generate_new_friendly_id? title_changed? end end
20.967742
109
0.698462
38bee8984b31d30f65bb28dcd6668ee13f03fd13
1,663
require File.expand_path('../../../spec_helper', __FILE__) require 'thread' describe "ConditionVariable#signal" do it "returns self if nothing to signal" do cv = ConditionVariable.new cv.signal.should == cv end it "returns self if something is waiting for a signal" do m = Mutex.new cv = ConditionVariable.new in_synchronize = false th = Thread.new do m.synchronize do in_synchronize = true cv.wait(m) end end # wait for m to acquire the mutex Thread.pass until in_synchronize # wait until th is sleeping (ie waiting) Thread.pass while th.status and th.status != "sleep" m.synchronize { cv.signal }.should == cv th.join end it "releases the first thread waiting in line for this resource" do m = Mutex.new cv = ConditionVariable.new threads = [] r1 = [] r2 = [] # large number to attempt to cause race conditions 100.times do |i| threads << Thread.new(i) do |tid| m.synchronize do r1 << tid cv.wait(m) r2 << tid end end end # wait for all threads to acquire the mutex the first time Thread.pass until m.synchronize { r1.size == threads.size } # wait until all threads are sleeping (ie waiting) Thread.pass until threads.all? {|th| th.status == "sleep" } r2.should be_empty 100.times do |i| m.synchronize do cv.signal end Thread.pass until r2.size == i+1 end threads.each {|t| t.join } # ensure that all the threads that went into the cv.wait are # released in the same order r2.should == r1 end end
23.757143
69
0.620565
5d27a450b6e91a29084b9bfef19f0360acc7f22b
51
module Docker module ApplicationHelper end end
10.2
26
0.803922
1861bd95d15dde538739d8b022a0c86f8a4329c1
270
require_relative 'spec_helper' describe 'datadog_agent' do describe file('/etc/datadog-agent') do it { is_expected.to be_directory } end describe service('datadog-agent') do it { is_expected.to be_enabled } it { is_expected.to be_running } end end
20.769231
40
0.718519
b9f7c954d03b858b4fe18f7cd6cde1b9e73051e8
579
class Entry < ActiveRecord::Base attr_accessor :validation_should_fail def validate errors.add("image","some stupid error") if @validation_should_fail end def after_assign @after_assign_called = true end def after_assign_called? @after_assign_called end def after_save @after_save_called = true end def after_save_called? @after_save_called end def my_store_dir # not really dynamic but at least it could be... "my_store_dir" end def load_image_with_rmagick(path) Magick::Image::read(path).first end end
17.545455
70
0.716753
f8f5c4d61dfe67431c1c944679409a7fc561a946
139
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_Centrum_session'
34.75
77
0.805755
ffc09f5786df2ab6fead4b3304b6067fd8d8db99
90
module Referrer class Engine < ::Rails::Engine isolate_namespace Referrer end end
15
32
0.744444
627d209c93066f540eca58fb38058745382ff6b4
293
Aws.add_service(:ForecastService, { api: "#{Aws::API_DIR}/forecast/2018-06-26/api-2.json", docs: "#{Aws::API_DIR}/forecast/2018-06-26/docs-2.json", examples: "#{Aws::API_DIR}/forecast/2018-06-26/examples-1.json", paginators: "#{Aws::API_DIR}/forecast/2018-06-26/paginators-1.json", })
41.857143
70
0.692833
61b07e92f2c2e1a32426618f565edbbd90872c39
2,160
require 'open-uri' module RegistrationValidation extend ActiveSupport::Concern include AppSettings included do validate :invite_code_valid, on: :create if app_setting("user_authentication_codes") end private def invite_code_valid self.email = self.email.downcase self.errors.add(:ticket_id, I18n.t(:invalid_membership_code)) if !Ticket.exists?(id_code: self.ticket_id) self.errors.add(:ticket_id, I18n.t(:invalid_membership_code)) if !Ticket.exists?(email: self.email) self.errors.add(:ticket_id, I18n.t(:membership_code_registered)) if User.exists?(ticket_id: self.ticket_id) self.errors.add(:ticket_id, I18n.t(:membership_code_registered)) if User.eixsts?(email: self.email) # Check if ticket exists in the local database to prevent going to remote server return if ticket = Ticket.find_by(id_code: self.ticket_id, email: self.email) self.errors.clear if invite_code_remote_tickets_valid end def invite_code_remote_tickets_valid return unless app_setting("user_authentication_vs_tixwise") && ENV['TICKETS_EVENT_URL'] return unless parseTixWiseAsHash[self.email] == self.ticket_id return if User.exists?(ticket_id: self.ticket_id) || User.exists?(email: self.email) Ticket.create(id_code: self.ticket_id, email: self.email) end def parseTixWiseAsHash event = Nokogiri::XML(open(ENV['TICKETS_EVENT_URL'])) tickets = event.css("tixwise_response RESPONSE event_listPurchases TicketPurchaseItem") emailPhoneNumber = tickets.css('TicketPurchaseItem email, TicketPurchaseItem phone_number') emailPhoneHash = Hash.new return emailPhoneHash if emailPhoneNumber.length <= 0 # the array is [email1,phone1,email2,phone2] and we want to hash it # Iterate over the array removing the last number for i in 0..emailPhoneNumber.length-1 next if i.odd? email = emailPhoneNumber[i].text.downcase phonenumber = emailPhoneNumber[i+1].text.tr('-', '') emailPhoneHash[email] = phonenumber end emailPhoneHash rescue SocketError => e self.errors.add(:ticket_id, e.message) puts e.message end end
38.571429
112
0.739352
210c4d49ead6c59edddd60a7f97143f62f0fe292
1,192
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Auxiliary include Msf::Exploit::Capture include Msf::Auxiliary::Scanner def initialize super( 'Name' => 'Simple IP Spoofing Tester', 'Description' => 'Simple IP Spoofing Tester', 'Author' => 'hdm', 'License' => MSF_LICENSE ) begin require 'pcaprub' @@havepcap = true rescue ::LoadError @@havepcap = false end deregister_options('FILTER','PCAPFILE') end def run_host(ip) open_pcap p = PacketFu::UDPPacket.new p.ip_saddr = ip p.ip_daddr = ip p.ip_ttl = 255 p.udp_sport = 53 p.udp_dport = 53 p.payload = "HELLO WORLD" p.recalc ret = send(ip,p) if ret == :done print_good("#{ip}: Sent a packet to #{ip} from #{ip}") else print_error("#{ip}: Packet not sent. Check permissions & interface.") end close_pcap end def send(ip,pkt) begin capture_sendto(pkt, ip) rescue RuntimeError => e return :error end return :done end end
19.225806
75
0.605705
f78b2a3fd771c9d6c4a93140b354ae63a0289609
3,328
# This file is copied to spec/ when you run 'rails generate rspec:install' if ENV['COVERAGE'] require 'simplecov' SimpleCov.start 'rails' do add_filter '/config/' add_filter '/lib/rspec/formatters/user_flow_formatter.rb' add_filter '/lib/user_flow_exporter.rb' add_filter '/lib/deploy/migration_statement_timeout.rb' add_filter '/lib/tasks/create_test_accounts.rb' # this is loaded super early by the Gemfile so it gets ignored by SimpleCov # and sinks our coverage reports, so we ignore it add_filter '/app/services/lambda_jobs/git_ref.rb' end end ENV['RAILS_ENV'] = 'test' require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' require 'spec_helper' require 'email_spec' require 'factory_bot' # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.maintain_test_schema! # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end # in _spec.rb will both be required and run as specs, causing the specs to be # run twice. It is recommended that you do not name files matching this glob to # end with _spec.rb. You can configure this pattern with the --pattern # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } RSpec.configure do |config| config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! config.include EmailSpec::Helpers config.include EmailSpec::Matchers config.include AbstractController::Translation config.include Features::MailerHelper, type: :feature config.include Features::SessionHelper, type: :feature config.include Features::StripTagsHelper, type: :feature config.include AnalyticsHelper config.include AwsKmsClientHelper config.include KeyRotationHelper config.include TwilioHelper config.before(:suite) do Rails.application.load_seed begin REDIS_POOL.with { |cache| cache.pool.with(&:info) } rescue RuntimeError => error puts error puts 'It appears Redis is not running, but it is required for (some) specs to run' exit 1 end end config.before(:each) do I18n.locale = :en end config.before(:each, js: true) do allow(Figaro.env).to receive(:domain_name).and_return('127.0.0.1') end config.before(:each, type: :controller) do @request.host = Figaro.env.domain_name end config.before(:each) do allow(ValidateEmail).to receive(:mx_valid?).and_return(true) end config.before(:each) do Telephony::Test::Message.clear_messages Telephony::Test::Call.clear_calls end config.around(:each, user_flow: true) do |example| Capybara.current_driver = :rack_test example.run Capybara.use_default_driver end config.before(:each) do IdentityDocAuth::Mock::DocAuthMockClient.reset! end config.around(:each, type: :feature) do |example| Bullet.enable = true example.run Bullet.enable = false end config.before(:each) do stub_request(:post, 'https://www.google-analytics.com/collect') end end
31.396226
88
0.734075
ff5361bd5d8761d7ba7a80075488555ca79d3d0e
3,171
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. SmartEnv.set :RAILS_DB_POOLSIZE, default: '5' SmartEnv.set :RAILS_DB_HOST, default: 'localhost' SmartEnv.set :RAILS_DB_NAME, default: 'chouette_test' SmartEnv.set :RAILS_DB_USER, default: nil SmartEnv.set :RAILS_HOST, default: 'http://www.example.com' SmartEnv.set :IEV_URL, default: 'http://localhost:8080' # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test config.action_mailer.default_options = { from: 'Chouette <[email protected]>' } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true config.accept_user_creation = false config.chouette_authentication_settings = { type: 'cas', cas_server: 'http://cas-portal.example.com/sessions' } # file to data for demo config.demo_data = 'tmp/demo.zip' config.action_mailer.default_url_options = { host: 'localhost:3000' } # Configure the e-mail address which will be shown in Devise::Maile config.mailer_sender = '[email protected]' # change to true to allow email to be sent during development config.action_mailer.perform_deliveries = false config.action_mailer.raise_delivery_errors = false config.action_mailer.default charset: 'utf-8' config.i18n.available_locales = %i[fr en] if ENV['VERBOSE_SPECS'].present? config.logger = Logger.new(STDOUT) config.logger.level = Logger::ERROR config.active_record.logger = nil end config.additional_compliance_controls << "dummy" config.additional_destinations << "dummy" config.enable_transactional_checksums = true end Dir[File.join(File.dirname(__FILE__), File.basename(__FILE__, ".rb"), "*.rb")].each do |f| eval File.read(f), nil, f end
37.75
90
0.760013
26abe0b3659afd619e975b4c7bc0810ccdf31244
2,098
class SourceRefreshService def initialize(source) @source = source end def process if @source.refresh_task_id.nil? dispatch_refresh_upload_task else task = Task.find(@source.refresh_task_id) if task.status == "error" dispatch_refresh_upload_task return self end if task.state == "completed" if task.child_task_id.nil? Rails.logger.error("Waiting for payload, please try again later") raise CatalogInventory::Exceptions::RefreshAlreadyRunningException, "Waiting for payload" end persister_task = Task.find(task.child_task_id) if persister_task.state == "completed" dispatch_refresh_upload_task else Rails.logger.error("PersisterTask #{persister_task.id} is running, please try again later") raise CatalogInventory::Exceptions::RefreshAlreadyRunningException, "PersisterTask #{persister_task.id} is running" end else Rails.logger.error("Uploading Task #{task.id} is running, please try again later") raise CatalogInventory::Exceptions::RefreshAlreadyRunningException, "UploadTask #{task.id} is running" end end self end private def dispatch_refresh_upload_task @source.with_lock("FOR UPDATE NOWAIT") do create_refresh_upload_task @source.save! end rescue ActiveRecord::LockWaitTimeout Rails.logger.error("Source #{@source.id} is locked for updating, please try again later") raise CatalogInventory::Exceptions::RecordLockedException, "Source #{@source.id} is locked" end def create_refresh_upload_task opts = {:tenant_id => @source.tenant_id, :source_id => @source.id} upload_task = if @source.last_successful_refresh_at.present? IncrementalRefreshUploadTaskService.new(opts.merge!(:last_successful_refresh_at => @source.last_successful_refresh_at.iso8601)).process.task else FullRefreshUploadTaskService.new(opts).process.task end upload_task.dispatch end end
32.78125
160
0.690658
d5d2a728294d05a89c5e7cada3dfc0163cee35ef
1,081
module SecurityTypes def self.populate_security_types file_name = 'data/facilities_management/security_types.csv' ActiveRecord::Base.connection_pool.with_connection do |db| truncate_query = 'truncate table facilities_management_security_types;' db.query truncate_query CSV.read(file_name, headers: true).each do |row| column_names = row.headers.map { |i| "\"#{i}\"" }.join(',') values = row.fields.map { |i| "'#{i}'" }.join(',') query = "INSERT INTO facilities_management_security_types (#{column_names}) values (#{values})" db.query query end end rescue PG::Error => e puts e.message end end namespace :db do namespace :rm3830 do desc 'add building Security Types to the database' task security_types: :environment do DistributedLocks.distributed_lock(153) do p 'Loading security types static data' SecurityTypes.populate_security_types end end end desc 'add building Security Types to the database' task static: :'rm3830:security_types' do end end
30.885714
103
0.688252
e235051783cf233141182b174af15541e116e230
160
class Helpers def self.current_user(session) user = User.find(session[:user_id]) end def self.logged_in?(session) !!session[:user_id] end end
14.545455
39
0.6875
ed3d4f5c387df2bdb4601cb329d531edc759746c
394
Given /^there should be (\d+) currency_conversions?$/ do |n| expect(@currency_conversions).to_not be_nil expect(@currency_conversions.count).to eq(n.to_i) end Given /^the currency_conversion is (\d+)$/ do |conversion_rate| BitcoinPayable::CurrencyConversion.create!( currency: 1, btc: conversion_rate.to_i, ) @currency_conversions = BitcoinPayable::CurrencyConversion.all end
32.833333
64
0.753807
aba22ab8d8cc4444d6f5f1b90e416ac35cb3e4ff
209
class CreateHouses < ActiveRecord::Migration[5.2] def change create_table :houses do |t| t.string :name t.string :description t.integer :teacher_id t.timestamps end end end
19
49
0.655502
e84c3ce80b112ab97786484ce7d7edc5e575c1c0
394
RSpec.describe "`bartab download` command", type: :cli do it "executes `bartab help download` command successfully" do output = `bartab help download` expected_output = <<-OUT Usage: bartab download DESCRIPTION SOURCE DESTINATION Options: -h, [--help], [--no-help] # Display usage information Command description... OUT expect(output).to eq(expected_output) end end
23.176471
62
0.71066
03853b79e5b2cd179a66a0138e008fdaa98fd386
12,007
# -*- coding: binary -*- require 'rex/post/process' require 'rex/post/meterpreter/packet' require 'rex/post/meterpreter/client' require 'rex/post/meterpreter/channels/pools/stream_pool' require 'rex/post/meterpreter/extensions/stdapi/stdapi' require 'rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/image' require 'rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/io' require 'rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/memory' require 'rex/post/meterpreter/extensions/stdapi/sys/process_subsystem/thread' module Rex module Post module Meterpreter module Extensions module Stdapi module Sys ## # # This class implements the Rex::Post::Process interface. # ## class Process < Rex::Post::Process include Rex::Post::Meterpreter::ObjectAliasesContainer ## # # Class methods # ## class << self attr_accessor :client end # # Returns the process identifier of the process supplied in key if it's # valid. # def Process.[](key) return if key.nil? each_process { |p| if (p['name'].downcase == key.downcase) return p['pid'] end } return nil end # # Attachs to the supplied process with a given set of permissions. # def Process.open(pid = nil, perms = nil) real_perms = 0 if (perms == nil) perms = PROCESS_ALL end if (perms & PROCESS_READ) real_perms |= PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_QUERY_INFORMATION end if (perms & PROCESS_WRITE) real_perms |= PROCESS_SET_SESSIONID | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION end if (perms & PROCESS_EXECUTE) real_perms |= PROCESS_TERMINATE | PROCESS_CREATE_THREAD | PROCESS_CREATE_PROCESS | PROCESS_SUSPEND_RESUME end return _open(pid, real_perms) end # # Low-level process open. # def Process._open(pid, perms, inherit = false) request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_ATTACH) if (pid == nil) pid = 0 end # Populate the request request.add_tlv(TLV_TYPE_PID, pid) request.add_tlv(TLV_TYPE_PROCESS_PERMS, perms) request.add_tlv(TLV_TYPE_INHERIT, inherit) # Transmit the request response = self.client.send_request(request) handle = response.get_tlv_value(TLV_TYPE_HANDLE) # If the handle is valid, allocate a process instance and return it if (handle != nil) return self.new(pid, handle) end return nil end # # Executes an application using the arguments provided # # Hash arguments supported: # # Hidden => true/false # Channelized => true/false # Suspended => true/false # InMemory => true/false # def Process.execute(path, arguments = nil, opts = nil) request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_EXECUTE) flags = 0 # If we were supplied optional arguments... if (opts != nil) if (opts['Hidden']) flags |= PROCESS_EXECUTE_FLAG_HIDDEN end if (opts['Channelized']) flags |= PROCESS_EXECUTE_FLAG_CHANNELIZED end if (opts['Suspended']) flags |= PROCESS_EXECUTE_FLAG_SUSPENDED end if (opts['UseThreadToken']) flags |= PROCESS_EXECUTE_FLAG_USE_THREAD_TOKEN end if (opts['Desktop']) flags |= PROCESS_EXECUTE_FLAG_DESKTOP end if (opts['Session']) flags |= PROCESS_EXECUTE_FLAG_SESSION request.add_tlv( TLV_TYPE_PROCESS_SESSION, opts['Session'] ) end if (opts['Subshell']) flags |= PROCESS_EXECUTE_FLAG_SUBSHELL end if (opts['Pty']) flags |= PROCESS_EXECUTE_FLAG_PTY end if (opts['ParentPid']) request.add_tlv(TLV_TYPE_PARENT_PID, opts['ParentPid']); request.add_tlv(TLV_TYPE_PROCESS_PERMS, PROCESS_ALL_ACCESS) request.add_tlv(TLV_TYPE_INHERIT, false) end inmem = opts['InMemory'] if inmem # add the file contents into the tlv f = ::File.new(path, 'rb') request.add_tlv(TLV_TYPE_VALUE_DATA, f.read(f.stat.size)) f.close # replace the path with the "dummy" path = inmem.kind_of?(String) ? inmem : 'cmd' end end request.add_tlv(TLV_TYPE_PROCESS_PATH, client.unicode_filter_decode( path )); # If process arguments were supplied if (arguments != nil) request.add_tlv(TLV_TYPE_PROCESS_ARGUMENTS, arguments); end request.add_tlv(TLV_TYPE_PROCESS_FLAGS, flags); response = client.send_request(request) # Get the response parameters pid = response.get_tlv_value(TLV_TYPE_PID) handle = response.get_tlv_value(TLV_TYPE_PROCESS_HANDLE) channel_id = response.get_tlv_value(TLV_TYPE_CHANNEL_ID) channel = nil # If we were creating a channel out of this if (channel_id != nil) channel = Rex::Post::Meterpreter::Channels::Pools::StreamPool.new(client, channel_id, "stdapi_process", CHANNEL_FLAG_SYNCHRONOUS, response) end # Return a process instance return self.new(pid, handle, channel) end # # Execute an application and capture the output # def Process.capture_output(path, arguments = nil, opts = nil, time_out = 15) start = Time.now.to_i process = execute(path, arguments, opts) data = "" # Wait up to time_out seconds for the first bytes to arrive while (d = process.channel.read) data << d if d == "" if Time.now.to_i - start < time_out sleep 0.1 else break end end end data.chomp! if data begin process.channel.close rescue IOError => e # Channel was already closed, but we got the cmd output, so let's soldier on. end process.close return data end # # Kills one or more processes. # def Process.kill(*args) request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_KILL) args.each { |id| request.add_tlv(TLV_TYPE_PID, id) } client.send_request(request) return true end # # Gets the process id that the remote side is executing under. # def Process.getpid request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_GETPID) response = client.send_request(request) return response.get_tlv_value(TLV_TYPE_PID) end # # Enumerates all of the elements in the array returned by get_processes. # def Process.each_process(&block) self.get_processes.each(&block) end # # Returns a ProcessList of processes as Hash objects with keys for 'pid', # 'ppid', 'name', 'path', 'user', 'session' and 'arch'. # def Process.get_processes request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_GET_PROCESSES) processes = ProcessList.new response = client.send_request(request) response.each(TLV_TYPE_PROCESS_GROUP) { |p| arch = "" pa = p.get_tlv_value(TLV_TYPE_PROCESS_ARCH) if !pa.nil? if pa == 1 # PROCESS_ARCH_X86 arch = ARCH_X86 elsif pa == 2 # PROCESS_ARCH_X64 arch = ARCH_X64 end else arch = p.get_tlv_value(TLV_TYPE_PROCESS_ARCH_NAME) end processes << { 'pid' => p.get_tlv_value(TLV_TYPE_PID), 'ppid' => p.get_tlv_value(TLV_TYPE_PARENT_PID), 'name' => client.unicode_filter_encode( p.get_tlv_value(TLV_TYPE_PROCESS_NAME) ), 'path' => client.unicode_filter_encode( p.get_tlv_value(TLV_TYPE_PROCESS_PATH) ), 'session' => p.get_tlv_value(TLV_TYPE_PROCESS_SESSION), 'user' => client.unicode_filter_encode( p.get_tlv_value(TLV_TYPE_USER_NAME) ), 'arch' => arch } } return processes end # # An alias for get_processes. # def Process.processes self.get_processes end ## # # Instance methods # ## # # Initializes the process instance and its aliases. # def initialize(pid, handle, channel = nil) self.client = self.class.client self.handle = handle self.channel = channel # If the process identifier is zero, then we must lookup the current # process identifier if (pid == 0) self.pid = client.sys.process.getpid else self.pid = pid end initialize_aliases( { 'image' => Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessSubsystem::Image.new(self), 'io' => Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessSubsystem::IO.new(self), 'memory' => Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessSubsystem::Memory.new(self), 'thread' => Rex::Post::Meterpreter::Extensions::Stdapi::Sys::ProcessSubsystem::Thread.new(self), }) # Ensure the remote object is closed when all references are removed ObjectSpace.define_finalizer(self, self.class.finalize(client, handle)) end def self.finalize(client, handle) proc { self.close(client, handle) } end # # Returns the executable name of the process. # def name return get_info()['name'] end # # Returns the path to the process' executable. # def path return get_info()['path'] end # # Closes the handle to the process that was opened. # def self.close(client, handle) request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_CLOSE) request.add_tlv(TLV_TYPE_HANDLE, handle) client.send_request(request, nil) handle = nil; return true end # # Instance method # def close(handle = self.handle) unless self.pid.nil? ObjectSpace.undefine_finalizer(self) self.class.close(self.client, handle) self.pid = nil end end # # Block until this process terminates on the remote side. # By default we choose not to allow a packet responce timeout to # occur as we may be waiting indefinatly for the process to terminate. # def wait( timeout = -1 ) request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_WAIT) request.add_tlv(TLV_TYPE_HANDLE, self.handle) self.client.send_request(request, timeout) self.handle = nil return true end attr_reader :client, :handle, :channel, :pid # :nodoc: protected attr_writer :client, :handle, :channel, :pid # :nodoc: # # Gathers information about the process and returns a hash. # def get_info request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_GET_INFO) info = {} request.add_tlv(TLV_TYPE_HANDLE, handle) # Send the request response = client.send_request(request) # Populate the hash info['name'] = client.unicode_filter_encode( response.get_tlv_value(TLV_TYPE_PROCESS_NAME) ) info['path'] = client.unicode_filter_encode( response.get_tlv_value(TLV_TYPE_PROCESS_PATH) ) return info end end # # Simple wrapper class for storing processes # class ProcessList < Array # # Create a Rex::Text::Table out of the processes stored in this list # # +opts+ is passed on to Rex::Text::Table.new, mostly unmolested # # Note that this output is affected by Rex::Post::Meterpreter::Client#unicode_filter_encode # def to_table(opts={}) if empty? return Rex::Text::Table.new(opts) end column_headers = [ "PID", "PPID", "Name", "Arch", "Session", "User", "Path" ] column_headers.delete_if do |h| none? { |process| process.has_key?(h.downcase) } || all? { |process| process[h.downcase].nil? } end opts = { 'Header' => 'Process List', 'Indent' => 1, 'Columns' => column_headers }.merge(opts) tbl = Rex::Text::Table.new(opts) each do |process| tbl << column_headers.map do |header| col = header.downcase next unless process.keys.any? { |process_header| process_header == col } val = process[col] if col == 'session' val == 0xFFFFFFFF ? '' : val.to_s else val end end end tbl end end end; end; end; end; end; end
25.655983
127
0.663696
28c65240932277f79dfcfd5d7aadfcce473b4c34
972
# Require any additional compass plugins here. # Set this to the root of your project when deployed: # (unused so far): http_path = "/" # Output to parent of build directory css_dir = ".." sass_dir = "scss" # (unused so far): images_dir = "modules/img" # (unused so far): javascripts_dir = "modules/js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed output_style = :expanded # To enable relative paths to assets via compass helper functions. Uncomment: relative_assets = true # To disable debugging comments that display the original location of your selectors. Uncomment: line_comments = true # If you prefer the indented syntax, you might want to regenerate this # project again passing --syntax sass, or you can uncomment this: # preferred_syntax = :sass # and then run: # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
34.714286
96
0.742798
794d2e6597de15563b25b9108023ed2df55741e6
21,778
require "refile/active_record_helper" require_relative "support/accepts_attachments_for_shared_examples" describe Refile::Attachment do let(:options) { {} } let(:klass) do opts = options Class.new do extend Refile::Attachment attr_accessor :document_id, :document_filename, :document_size, :document_content_type attachment :document, **opts end end let(:instance) { klass.new } describe ":name=" do it "receives a file, caches it and sets the _id parameter" do instance.document = Refile::FileDouble.new("hello", "foo.txt", content_type: "text/plain") expect(instance.document.read).to eq("hello") expect(instance.document_attacher.data[:filename]).to eq("foo.txt") expect(instance.document_attacher.data[:size]).to eq(5) expect(instance.document_attacher.data[:content_type]).to eq("text/plain") expect(instance.document_filename).to eq("foo.txt") expect(instance.document_size).to eq(5) expect(instance.document_content_type).to eq("text/plain") end it "receives serialized data and retrieves file from it" do file = Refile.cache.upload(Refile::FileDouble.new("hello")) instance.document = { id: file.id, filename: "foo.txt", content_type: "text/plain", size: 5 }.to_json expect(instance.document.read).to eq("hello") expect(instance.document_attacher.data[:filename]).to eq("foo.txt") expect(instance.document_attacher.data[:size]).to eq(5) expect(instance.document_attacher.data[:content_type]).to eq("text/plain") expect(instance.document_filename).to eq("foo.txt") expect(instance.document_size).to eq(5) expect(instance.document_content_type).to eq("text/plain") end it "receives parsed data and retrieves file from it" do file = Refile.cache.upload(Refile::FileDouble.new("hello")) instance.document = { id: file.id, filename: "foo.txt", content_type: "text/plain", size: 5 } expect(instance.document.read).to eq("hello") expect(instance.document_attacher.data[:filename]).to eq("foo.txt") expect(instance.document_attacher.data[:size]).to eq(5) expect(instance.document_attacher.data[:content_type]).to eq("text/plain") expect(instance.document_filename).to eq("foo.txt") expect(instance.document_size).to eq(5) expect(instance.document_content_type).to eq("text/plain") end it "does nothing when assigned string lacks an id" do instance.document = { size: 5 }.to_json expect(instance.document).to be_nil expect(instance.document_size).to be_nil end it "does nothing when assigned string is not valid JSON" do instance.document = "size:f{oo}" expect(instance.document).to be_nil expect(instance.document_size).to be_nil end it "accepts nil" do instance.document = nil expect(instance.document).to be_nil end it "removes a document when assigned nil" do instance.document = Refile::FileDouble.new("hello", "foo.txt", content_type: "text/plain") instance.document = nil expect(instance.document).to be_nil end end describe ":name" do it "gets a file from the store" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id expect(instance.document.id).to eq(file.id) end it "complains when `id` attribute not readable" do klass.class_eval do undef :document_id end expect do instance.document end.to raise_error(NoMethodError) end end describe ":url" do it "generates URL with extra options" do allow(Refile).to receive(:token).and_return("token") file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id expect(instance.document_url("fill", 800, 800)).to eq("http://localhost:56120/attachments/token/store/fill/800/800/#{file.id}/document") end end describe "presigned_:name_url=" do it "generates presigned URL" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id allow(Refile.store).to receive_message_chain(:object, :presigned_url).with(file.id).with(:get, expires_in: 900).and_return("PRESIGNED_URL") expect(instance.presigned_document_url).to eq("PRESIGNED_URL") end it "generates presigned URL with custom expiration" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id allow(Refile.store).to receive_message_chain(:object, :presigned_url).with(file.id).with(:get, expires_in: 901).and_return("PRESIGNED_URL") expect(instance.presigned_document_url(901)).to eq("PRESIGNED_URL") end it "does nothing when id is nill" do expect(instance.presigned_document_url).to be_nil end end describe "remote_:name_url=" do it "does nothing when nil is assigned" do instance.remote_document_url = nil expect(instance.document).to be_nil end it "does nothing when empty string is assigned" do instance.remote_document_url = nil expect(instance.document).to be_nil end context "without redirects" do before(:each) do stub_request(:get, "http://www.example.com/some_file.txt").to_return( status: 200, body: "abc", headers: { "Content-Length" => 3, "Content-Type" => "text/plain" } ) end it "downloads file, caches it and sets the _id parameter and metadata" do instance.remote_document_url = "http://www.example.com/some_file.txt" expect(instance.document.read).to eq("abc") expect(instance.document_attacher.data[:filename]).to eq("some_file.txt") expect(instance.document_attacher.data[:size]).to eq(3) expect(instance.document_attacher.data[:content_type]).to eq("text/plain") expect(instance.document_filename).to eq("some_file.txt") expect(instance.document_size).to eq(3) expect(instance.document_content_type).to eq("text/plain") expect(Refile.cache.get(instance.document.id).read).to eq("abc") end end context "with redirects" do before(:each) do stub_request(:get, "http://www.example.com/1").to_return(status: 302, headers: { "Location" => "http://www.example.com/2" }) stub_request(:get, "http://www.example.com/2").to_return(status: 200, body: "woop", headers: { "Content-Length" => 4 }) stub_request(:get, "http://www.example.com/loop").to_return(status: 302, headers: { "Location" => "http://www.example.com/loop" }) end it "follows redirects and fetches the file, caches it and sets the _id parameter" do instance.remote_document_url = "http://www.example.com/1" expect(instance.document.read).to eq("woop") expect(Refile.cache.get(instance.document.id).read).to eq("woop") end context "when errors enabled" do let(:options) { { raise_errors: true } } it "handles redirect loops by trowing errors" do expect do instance.remote_document_url = "http://www.example.com/loop" end.to raise_error(Refile::TooManyRedirects) end end context "when errors disabled" do let(:options) { { raise_errors: false } } it "handles redirect loops by setting generic download error" do expect do instance.remote_document_url = "http://www.example.com/loop" end.not_to raise_error expect(instance.document_attacher.errors).to eq([:download_failed]) expect(instance.document).to be_nil end end end end describe ":name_attacher.store!" do it "puts a cached file into the store" do instance.document = Refile::FileDouble.new("hello") cache = instance.document instance.document_attacher.store! expect(Refile.store.get(instance.document_id).read).to eq("hello") expect(Refile.store.get(instance.document.id).read).to eq("hello") expect(instance.document.read).to eq("hello") expect(instance.document_size).to eq(5) expect(Refile.cache.get(cache.id).exists?).to be_falsy end it "complains when `id` attribute not writable" do instance.document = Refile::FileDouble.new("hello") klass.class_eval do undef :document_id= end expect do instance.document_attacher.store! end.to raise_error(NoMethodError) end it "does nothing when not cached" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id instance.document_attacher.store! expect(Refile.store.get(instance.document_id).read).to eq("hello") expect(Refile.store.get(instance.document.id).read).to eq("hello") end it "overwrites previously stored file" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id instance.document = Refile::FileDouble.new("world") cache = instance.document instance.document_attacher.store! expect(Refile.store.get(instance.document_id).read).to eq("world") expect(Refile.store.get(instance.document.id).read).to eq("world") expect(instance.document.read).to eq("world") expect(Refile.cache.get(cache.id).exists?).to be_falsy expect(Refile.store.get(file.id).exists?).to be_falsy end it "removes an uploaded file when remove? returns true" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id instance.document_attacher.remove = true instance.document_attacher.store! expect(instance.document_id).to be_nil expect(Refile.store.exists?(file.id)).to be_falsy end it "removes metadata when remove? returns true" do file = Refile.store.upload(Refile::FileDouble.new("hello")) instance.document_id = file.id instance.document_size = file.size instance.document_filename = "foo" instance.document_content_type = "bar" instance.document_attacher.remove = true instance.document_attacher.store! expect(instance.document_id).to be_nil expect(instance.document_size).to be_nil expect(instance.document_filename).to be_nil expect(instance.document_content_type).to be_nil end end describe ":name_attacher.delete!" do it "deletes a stored file" do instance.document = Refile::FileDouble.new("hello") instance.document_attacher.store! file = instance.document instance.document_attacher.delete! expect(Refile.store.exists?(file.id)).to be_falsy end it "deletes a cached file" do instance.document = Refile::FileDouble.new("hello") file = instance.document instance.document_attacher.delete! expect(Refile.cache.exists?(file.id)).to be_falsy end end describe ":name_attacher.remove?" do it "should be true when the value is truthy" do instance.document_attacher.remove = true expect(instance.document_attacher.remove?).to be_truthy end it "should be false when the value is falsey" do instance.document_attacher.remove = false expect(instance.document_attacher.remove?).to be_falsy end it "should be false when the value is ''" do instance.document_attacher.remove = "" expect(instance.document_attacher.remove?).to be_falsy end it "should be false when the value is '0'" do instance.document_attacher.remove = "0" expect(instance.document_attacher.remove?).to be_falsy end it "should be false when the value is 'false'" do instance.document_attacher.remove = "false" expect(instance.document_attacher.remove?).to be_falsy end end describe ":name_attacher.valid?" do let(:options) { { type: :image, raise_errors: false } } it "returns false if no file is attached" do expect(instance.document_attacher.valid?).to be_falsy end it "returns true if valid file is attached" do file = Refile::FileDouble.new("hello", content_type: "image/png") instance.document = file expect(instance.document_attacher.valid?).to be_truthy end it "returns false and sets errors if invalid file is attached" do file = Refile::FileDouble.new("hello", content_type: "text/plain") instance.document = file expect(instance.document_attacher.valid?).to be_falsy expect(instance.document_attacher.errors).to match_array [[:invalid_content_type, anything]] end it "returns false and sets errors if file with zero byte is uploaded" do file = Refile::FileDouble.new("", "hello", content_type: "image/png") instance.document = file expect(instance.document_attacher.valid?).to be_falsy expect(instance.document_attacher.errors).to eq([:zero_byte_detected]) end end describe ":name_attacher.extension" do it "is nil when not inferrable" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.extension).to be_nil end it "is inferred from the filename" do file = Refile::FileDouble.new("hello", "hello.txt") instance.document = file expect(instance.document_attacher.extension).to eq("txt") end it "is inferred from the content type" do file = Refile::FileDouble.new("hello", content_type: "image/png") instance.document = file expect(instance.document_attacher.extension).to eq("png") end it "returns nil with unknown content type" do file = Refile::FileDouble.new("hello", content_type: "foo/doesnotexist") instance.document = file expect(instance.document_attacher.extension).to be_nil end it "is nil when filename has no extension" do file = Refile::FileDouble.new("hello", "hello") instance.document = file expect(instance.document_attacher.extension).to be_nil end end describe ":name_attacher.basename" do it "is nil when not inferrable" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.basename).to be_nil end it "is inferred from the filename" do file = Refile::FileDouble.new("hello", "hello.txt") instance.document = file expect(instance.document_attacher.basename).to eq("hello") end it "returns filename if filename has no extension" do file = Refile::FileDouble.new("hello", "hello") instance.document = file expect(instance.document_attacher.basename).to eq("hello") end end describe ":name_attacher.error" do let(:options) { { cache: :limited_cache, raise_errors: false } } it "is blank when valid file uploaded" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.errors).to be_empty expect(Refile.cache.get(instance.document.id).exists?).to be_truthy end it "contains a list of errors when invalid file uploaded" do file = Refile::FileDouble.new("a" * 120) instance.document = file expect(instance.document_attacher.errors).to eq([:too_large]) expect(instance.document).to be_nil end it "is reset when valid file uploaded" do file = Refile::FileDouble.new("a" * 120) instance.document = file file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.errors).to be_empty expect(Refile.cache.get(instance.document.id).exists?).to be_truthy end end describe ":name_definition.accept" do context "with `extension`" do let(:options) { { extension: %w[jpg png] } } it "returns an accept string" do expect(instance.document_attachment_definition.accept).to eq(".jpg,.png") end end context "with `content_type`" do let(:options) { { content_type: %w[image/jpeg image/png], extension: "zip" } } it "returns an accept string" do expect(instance.document_attachment_definition.accept).to eq("image/jpeg,image/png") end end end describe "with option `raise_errors: true" do let(:options) { { cache: :limited_cache, raise_errors: true } } it "raises an error when invalid file assigned" do file = Refile::FileDouble.new("a" * 120) expect do instance.document = file end.to raise_error(Refile::Invalid) expect(instance.document_attacher.errors).to eq([:too_large]) expect(instance.document).to be_nil end end describe "with option `raise_errors: false" do let(:options) { { cache: :limited_cache, raise_errors: false } } it "does not raise an error when invalid file assigned" do file = Refile::FileDouble.new("a" * 120) instance.document = file expect(instance.document_attacher.errors).to eq([:too_large]) expect(instance.document).to be_nil end end describe "with option `extension`: %w[txt]`" do let(:options) { { extension: "txt", raise_errors: false } } it "allows file with correct extension to be uploaded" do file = Refile::FileDouble.new("hello", "hello.txt") instance.document = file expect(instance.document_attacher.errors).to be_empty expect(Refile.cache.get(instance.document.id).exists?).to be_truthy end it "sets error when file with other extension is uploaded" do file = Refile::FileDouble.new("hello", "hello.php") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_extension, anything]] expect(instance.document).to be_nil end it "sets error when file with no extension is uploaded" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_extension, anything]] expect(instance.document).to be_nil end end describe "with option `content_type: %w[txt]`" do let(:options) { { content_type: "text/plain", raise_errors: false } } it "allows file with correct content type to be uploaded" do file = Refile::FileDouble.new("hello", content_type: "text/plain") instance.document = file expect(instance.document_attacher.errors).to be_empty expect(Refile.cache.get(instance.document.id).exists?).to be_truthy end it "sets error when file with other content type is uploaded" do file = Refile::FileDouble.new("hello", content_type: "application/php") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_content_type, anything]] expect(instance.document).to be_nil end it "sets error when file with no content type is uploaded" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_content_type, anything]] expect(instance.document).to be_nil end end describe "with option `type: :image`" do let(:options) { { type: :image, raise_errors: false } } it "allows image to be uploaded" do file = Refile::FileDouble.new("hello", content_type: "image/jpeg") instance.document = file expect(instance.document_attacher.errors).to be_empty expect(Refile.cache.get(instance.document.id).exists?).to be_truthy end it "sets error when file with other content type is uploaded" do file = Refile::FileDouble.new("hello", content_type: "application/php") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_content_type, anything]] expect(instance.document).to be_nil end it "sets error when file with no content type is uploaded" do file = Refile::FileDouble.new("hello") instance.document = file expect(instance.document_attacher.errors).to match_array [[:invalid_content_type, anything]] expect(instance.document).to be_nil end end it "includes the module with methods in an instrospectable way" do expect { puts klass.ancestors } .to output(/Refile::Attachment\(document\)/).to_stdout expect { p klass.ancestors } .to output(/Refile::Attachment\(document\)/).to_stdout end describe ".accepts_nested_attributes_for" do it_should_behave_like "accepts_attachments_for" do let(:options) { {} } # This class is a PORO, but it's implementing an interface that's similar # to ActiveRecord's in order to simplify specs via shared examples. let(:post_class) do opts = options foo = document_class Class.new do extend Refile::Attachment attr_accessor :documents accepts_attachments_for( :documents, accessor_prefix: "documents_files", collection_class: foo, **opts ) def initialize(attributes) @documents = attributes[:documents] end def save!; end def update_attributes!(attributes) attributes.each { |k, v| public_send("#{k}=", v) } end end end let(:document_class) do Class.new do extend Refile::Attachment attr_accessor :file_id attachment :file, type: :image, extension: %w[jpeg], raise_errors: false def initialize(attributes = {}) self.file = attributes[:file] end end end let(:post) { post_class.new(documents: []) } end end end
33.81677
145
0.676279
7aefa9cfb8bc8c23c3b9d75a79937f4375e3b32e
348
require 'isolated_spec_helper' RSpec.describe 'ActiveType::Object', type: :isolated do it 'does not need a database connection' do require 'active_type' expect { klass = Class.new(ActiveType::Object) do attribute :foo, :integer end expect(klass.new(foo: '15').foo).to eq 15 }.not_to raise_error end end
21.75
55
0.666667
21cfb5364689b4b42025c61487e6fcdcd2c104b0
1,619
require 'test_helper' class UsersLoginTest < ActionDispatch::IntegrationTest def setup @user = users(:michael) end test "login with invalid information" do get login_path assert_template 'sessions/new' post login_path, params: { session: { email: "", password: "" } } assert_template 'sessions/new' assert_not flash.empty? get root_path assert flash.empty? end test "login with valid information followed by logout" do get login_path post login_path, params: { session: { email: @user.email, password: 'password' } } assert is_logged_in? assert_redirected_to @user follow_redirect! assert_template 'users/show' assert_select "a[href=?]", login_path, count: 0 assert_select "a[href=?]", logout_path assert_select "a[href=?]", user_path(@user) delete logout_path assert_not is_logged_in? assert_redirected_to root_url # Simulate a user clicking logout in a second window. delete logout_path follow_redirect! assert_select "a[href=?]", login_path assert_select "a[href=?]", logout_path, count: 0 assert_select "a[href=?]", user_path(@user), count: 0 end test "login with remembering" do log_in_as(@user, remember_me: '1') assert_not_empty cookies['remember_token'] end test "login without remembering" do # Log in to set the cookie. log_in_as(@user, remember_me: '1') # Log in again and verify that the cookie is deleted. log_in_as(@user, remember_me: '0') assert_empty cookies['remember_token'] end end
29.436364
69
0.671402
ed4cdba071b07331c5bbbfac24f3bccf0bbcad40
2,769
# Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::Web::Mgmt::V2016_09_01 module Models # # Collection of metric responses. # class ResourceMetricCollection include MsRestAzure include MsRest::JSONable # @return [Array<ResourceMetric>] Collection of resources. attr_accessor :value # @return [String] Link to next page of resources. attr_accessor :next_link # return [Proc] with next page method call. attr_accessor :next_method # # Gets the rest of the items for the request, enabling auto-pagination. # # @return [Array<ResourceMetric>] operation results. # def get_all_items items = @value page = self while page.next_link != nil && !page.next_link.strip.empty? do page = page.get_next_page items.concat(page.value) end items end # # Gets the next page of results. # # @return [ResourceMetricCollection] with next page content. # def get_next_page response = @next_method.call(@next_link).value! unless @next_method.nil? unless response.nil? @next_link = response.body.next_link @value = response.body.value self end end # # Mapper for ResourceMetricCollection class as Ruby Hash. # This will be used for serialization/deserialization. # def self.mapper() { client_side_validation: true, required: false, serialized_name: 'ResourceMetricCollection', type: { name: 'Composite', class_name: 'ResourceMetricCollection', model_properties: { value: { client_side_validation: true, required: true, serialized_name: 'value', type: { name: 'Sequence', element: { client_side_validation: true, required: false, serialized_name: 'ResourceMetricElementType', type: { name: 'Composite', class_name: 'ResourceMetric' } } } }, next_link: { client_side_validation: true, required: false, read_only: true, serialized_name: 'nextLink', type: { name: 'String' } } } } } end end end end
27.969697
80
0.523294
8773c87b73483de14f5962398665b6ba9e1b6033
20
require 'pdf_forms'
10
19
0.8
039ba73a68a8d7d39614a095c76b5d399b63896c
452
# frozen_string_literal: true ActiveSupport::Inflector.inflections do |inflect| inflect.acronym 'AWS' inflect.acronym 'CC' inflect.acronym 'DOD' inflect.acronym 'EMIS' inflect.acronym 'EVSS' inflect.acronym 'GI' inflect.acronym 'IHub' inflect.acronym 'PagerDuty' inflect.acronym 'PPIU' inflect.acronym 'SSOe' inflect.acronym 'VAOS' inflect.acronym 'VBA' inflect.acronym 'VIC' inflect.uncountable 'terms_and_conditions' end
23.789474
49
0.75
87e71359afc3f8259adb5175af36a3c1a0a90d51
139
module RocketAdminAssets class ApplicationMailer < ActionMailer::Base default from: '[email protected]' layout 'mailer' end end
19.857143
46
0.748201
185b270d1109b809898856202f558d3ca8c5b677
319
Rails.application.routes.draw do namespace :api do namespace :v1 do resources :bookings, only: %i[index create show update destroy] resources :cars, only: %i[index create show] end end resources :users post 'login', to: 'authentication#create' post 'signup', to: 'users#create' end
24.538462
69
0.673981
bbdeb62fab165d75b06452a1c36b7d1681edfeb8
324
module SkipStamp def self.included(base) base.class_eval do def record_timestamps ActiveRecord::Base.record_timestamps && self.class.record_timestamps && @skip_stamp.blank? end def skip_stamp @skip_stamp = true yield @skip_stamp = false end end end end
19.058824
98
0.635802
28b3c95dd61c7caedf1296179be9e09d28bd1133
3,075
require "spec_helper" RSpec.describe SqlAssess::QueryComparisonResult do subject { described_class.new(success: true, attributes: attributes) } let(:attributes) do SqlAssess::QueryAttributeExtractor.new.extract( ( <<-SQL.squish SELECT table1.a FROM table1 SQL ), ( <<-SQL.squish SELECT table1.a FROM table1 SQL ) ) end context "#attributes_grade" do it "returns a hash" do expect(subject.attributes_grade).to match({ columns: an_instance_of(BigDecimal), order_by: an_instance_of(BigDecimal), where: an_instance_of(BigDecimal), distinct_filter: an_instance_of(BigDecimal), limit: an_instance_of(BigDecimal), tables: an_instance_of(BigDecimal), group: an_instance_of(BigDecimal), having: an_instance_of(BigDecimal), }) end end context "#message" do context "with grade = 100" do before do allow_any_instance_of(described_class).to receive(:calculate_grade).and_return(1) end it { expect(subject.message).to eq("Congratulations! Your solution is correct") } end context "with grade < 100" do before do allow_any_instance_of(described_class).to receive(:calculate_grade).and_return(0.9) allow_any_instance_of(described_class).to receive(:first_wrong_component).and_return(component) end context "with columns first_wrong_attribute" do let(:component) { :columns } it { expect(subject.message).to eq("Your query is not correct. Check what columns you are selecting.") } end context "with tables first_wrong_attribute" do let(:component) { :tables } it { expect(subject.message).to eq("Your query is not correct. Are you sure you are selecting the right tables?") } end context "with order_by first_wrong_attribute" do let(:component) { :order_by } it { expect(subject.message).to eq("Your query is not correct. Are you ordering the rows correctly?") } end context "with where first_wrong_attribute" do let(:component) { :where } it { expect(subject.message).to eq("Your query is not correct. Looks like you are selecting the right columns, but you are not selecting only the correct rows.") } end context "with distinct_filter first_wrong_attribute" do let(:component) { :distinct_filter } it { expect(subject.message).to eq("Your query is not correct. What about duplicates? What does the exercise say?") } end context "with limit first_wrong_attribute" do let(:component) { :limit } it { expect(subject.message).to eq("Your query is not correct. Are you selecting the correct number of rows?") } end context "with group first_wrong_attribute" do let(:component) { :group } it { expect(subject.message).to eq("Your query is not correct. Are you grouping by the correct columns?") } end end end end
32.368421
171
0.658862
793d854048274a08908d94a01b330bbe38361f0c
229
# frozen_string_literal: true module Kaminari class Railtie < ::Rails::Railtie #:nodoc: # Doesn't actually do anything. Just keeping this hook point, mainly for compatibility initializer 'kaminari' do end end end
25.444444
90
0.733624
7aa76875f68c3d7f94bd6507f64a66f36dec89ca
2,482
# frozen_string_literal: true require "nhs_api_client/railtie" module NHSApiClient module Organisations class Client include HTTParty BASE_URL = "https://directory.spineservices.nhs.uk/ORD/2-0-0/organisations"\ "?PrimaryRoleId=<primary_role_id>"\ "&Limit=<page_size>" ROLE_CODES = { practices: "RO177", branch_surgeries: "RO96" }.freeze DEFAULT_PAGE_SIZE = 100 # quit_after is a kill switch that stops processing when the specificed number of # records (not pages) have been found. Useful when debugging to avoid hitting the API # excessively. eg quit_after: 10 # roles can be an array of symbols or just one def fetch_pages(roles:, options: {}) Array(roles).each do |role| url = initial_url_for(role, **options) page = PageTheFirst.new(url) quit_after = options[:quit_after].to_i item_count = 0 loop do GC.start # force garbage collection to prevent excessive memory usage page = page.next item_count += page.item_count yield(page) if block_given? break if page.next_url.nil? break if quit_after.positive? && item_count >= quit_after puts "#{page.offset + page.item_count} of #{page.total_count}" end end end private # Options: # - :last_change_date - if nil it will returns all records # - :page_size - the number of oragnisations per page def initial_url_for(role, **options) last_change_date = extract_last_change_date_from(options) page_size = options.fetch(:page_size, DEFAULT_PAGE_SIZE) role_code = ROLE_CODES.fetch(role.to_sym) url = BASE_URL .gsub("<primary_role_id>", role_code) .gsub("<page_size>", page_size.to_s) url += "&LastChangeDate=#{last_change_date}" if last_change_date.present? url end # The API only allows the LastChangeDate parameter to be a date up to 185 days ago, # so if the requested last_change_date is before then, use nil instead to get all # organisations - slower as we have to page through all organisations, but there is # no other way. def extract_last_change_date_from(options) date = options[:last_change_date] return if date.nil? return if Date.parse(date) < 184.days.ago date end end end end
35.457143
91
0.639001
1ce0d3adaf8dd47b0ec62750ce5dc5c6d898c2bc
604
require 'base64' begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end $KCODE = 'u' unless Cucumber::RUBY_1_9 Before('@not_used') do raise "Should never run" end After('@not_used') do raise "Should never run" end Before('@background_tagged_before_on_outline') do @cukes = '888' end After('@background_tagged_before_on_outline') do @cukes.should == '888' end After do png = IO.read(File.join(File.dirname(__FILE__), 'bubble_256x256.png')) encoded_img = Base64.encode64(png).gsub(/\n/, '') embed("data:image/png;base64,#{encoded_img}", 'image/png') end
22.37037
86
0.72351
e81458d3f46320d1890ebb433958d3ea27b72d44
931
# Hash monkey patches class Hash def symbolize_keys! transform_keys!{ |key| key.to_sym rescue key } end def deep_symbolize_keys! deep_transform_keys!{ |key| key.to_sym rescue key } end def transform_keys! return enum_for(:transform_keys!) unless block_given? keys.each do |key| self[yield(key)] = delete(key) end self end def deep_transform_keys!(&block) _deep_transform_keys_in_object!(self, &block) end def _deep_transform_keys_in_object!(object, &block) case object when Hash object.keys.each do |key| value = object.delete(key) object[yield(key)] = _deep_transform_keys_in_object!(value, &block) end object when Array object.map! {|e| _deep_transform_keys_in_object!(e, &block)} else object end end end
24.5
79
0.60043
3888875d6daac953ff1343bd3130eac4cff86119
1,412
#!/usr/bin/env ruby require 'json' require 'net/http' require 'yaml' require 'logger' logger = Logger.new('/var/log/dnsflare.log') logger.level = Logger::warn cloudflare_conf = YAML.load_file("/var/scripts/cloudflare.yaml") username = cloudflare_conf["username"] token = cloudflare_conf["token"] tld = cloudflare_conf["tld"] zones = cloudflare_conf["zones"] icanhazipuri = URI("http://icanhazip.com") local_ip = Net::HTTP.get(icanhazipuri).chomp("\n") logger.debug "local ip #{local_ip}" uri = URI("https://www.cloudflare.com/api_json.html") logger.debug "request for all records token: #{token}, email: #{username}, tld: #{tld}" response = Net::HTTP.post_form(uri, 'a' => 'rec_load_all', 'tkn' => token, 'email' => username, 'z' => tld).body json = JSON.parse(response) logger.debug "Json: #{json}" for zone in zones current_ip = json["response"]["recs"]["objs"].select {|obj| obj["name"] == zone}.first["content"] logger.debug "current ip: #{current_ip}" if local_ip != current_ip logger.warn "Updating IP, current ip: #{current_ip}, new ip: #{local_ip}" rec_id = json["response"]["recs"]["objs"].select {|obj| obj["name"] == zone}.first["rec_id"] final_resp = Net::HTTP.post_form(uri, 'a' => 'rec_edit', 'tkn' => token, 'id' => rec_id, 'email' => username, 'z' => tld, 'type' => 'A', 'name' => zone, 'content' => local_ip, 'service_mode' => '0', 'ttl' => '1') end end
37.157895
99
0.656516
bf5957654ff75dbca37e9d0b187a3fb9e74b7cad
1,326
# frozen_string_literal: true # Licensed to the Software Freedom Conservancy (SFC) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The SFC 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. module Selenium module WebDriver module Firefox # # Driver implementation for Firefox using GeckoDriver. # @api private # class Driver < WebDriver::Driver include DriverExtensions::HasAddons include DriverExtensions::HasWebStorage include DriverExtensions::PrintsPage def browser :firefox end def bridge_class Bridge end end # Driver end # Firefox end # WebDriver end # Selenium
29.466667
62
0.71267
0379500d4a493302bc9d1f0259a887583ac0411d
3,558
# frozen_string_literal: true class DelayedJobTestAdapter < ActiveJob::QueueAdapters::DelayedJobAdapter def enqueued_jobs Delayed::Job.all.to_a end def performed_jobs [] end end class TestCronJob < CronJob self.cron_expression = "* * * * *" def perform; end end module DelayedJobMatchers extend RSpec::Matchers::DSL # Usage: # expect(some_object).to delay_execution_of(:some_method).with(arguments / argument_matchers) # # Examples: # Object.delay.puts("hello") # # expect(Object).to delay_execution_of(:puts).with(an_instance_of String) #=> success # expect(Object).to delay_execution_of(:puts) #=> success # expect(Object).to delay_execution_of(:puts).with("hello") #=> success # expect(Object).to delay_execution_of(:puts).with("Hello") #=> failure # # Why: # # While rails provides a number of helpers to deal with enqueued jobs, those helpers are limited # in a number of ways making it impossible to test certain scenarios: # 1. Matchers are not aware of jobs scheduled outside of ActiveJob, e.g. calls like # `some_object.delay.some_method(argument)` is not inspectable via `enqueued_jobs` # 2. ActiveJob is not aware of database transactions and transactional behaviour of DelayedJob, # meaning that `enqueued_jobs` will contain jobs that has not been commited in the database. # # This matchers relies on the job record being stored in the database, fixing both the issues above # drastically improving our confidence in the unit tests. # # How: # # This is a bit complex and requires some knowledge about DelayedJob internals. DelayedJob allows # any object with `perform` method to be invoked as a background job. For `some_object.delay.some_method` # DJ creates an instance of PerformableMethod, which stores all `some_object`, `method_name` and `arguments` # and then stores this object in the database record serialized into YAML as `payload_object`. # # In order to asnwer the question "was the execution of some_method on some_object enqueued for execution with # given arguments", we need to query enqueued_jobs from the database based on that YAML column, DJ was # not desinged for querability. To do this, we recreate yaml representation of the payload_object. # At the time of writing, I've decided to limit the query by the some_object class and method name, as # it is possible that `some_object` state representation could be time sensitive. # # Once the list of potenital jobs matching criteria is returned from the database, we filter them # down manually to ensure given arguments matches expectations define :delay_execution_of do |method_name| match do |actual| jobs = query_jobs(actual, method_name) return jobs.any? unless @arguments jobs.any? do |job| @arguments.args_match?(*job.payload_object.args) end end chain :with do |*args| @arguments = RSpec::Mocks::ArgumentListMatcher.new(*args) end private def query_jobs(object, method_name) scope = Delayed::Job .where("handler LIKE '--- !ruby/object:Delayed::PerformableMethod%'") .where("handler LIKE ?", "%\nmethod_name: :#{method_name}\n%") scope.select do |job| return object == job.payload_object.object unless object.respond_to?(:matches?) object.matches? job.payload_object.object end end end RSpec.configure do |rspec| rspec.include self end end
37.851064
112
0.709106
62e7514b21494269f03b888b7dba754124a7213a
45,720
# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::DevTestLabs::Mgmt::V2016_05_15 # # The DevTest Labs Client. # class Disks include MsRestAzure # # Creates and initializes a new instance of the Disks class. # @param client service class for accessing basic functionality. # def initialize(client) @client = client end # @return [DevTestLabsClient] reference to the DevTestLabsClient attr_reader :client # # List disks in a given user profile. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param filter [String] The filter to apply to the operation. # @param top [Integer] The maximum number of resources to return from the # operation. # @param orderby [String] The ordering expression for the results, using OData # notation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array<Disk>] operation results. # def list(resource_group_name, lab_name, user_name, expand:nil, filter:nil, top:nil, orderby:nil, custom_headers:nil) first_page = list_as_lazy(resource_group_name, lab_name, user_name, expand:expand, filter:filter, top:top, orderby:orderby, custom_headers:custom_headers) first_page.get_all_items end # # List disks in a given user profile. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param filter [String] The filter to apply to the operation. # @param top [Integer] The maximum number of resources to return from the # operation. # @param orderby [String] The ordering expression for the results, using OData # notation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def list_with_http_info(resource_group_name, lab_name, user_name, expand:nil, filter:nil, top:nil, orderby:nil, custom_headers:nil) list_async(resource_group_name, lab_name, user_name, expand:expand, filter:filter, top:top, orderby:orderby, custom_headers:custom_headers).value! end # # List disks in a given user profile. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param filter [String] The filter to apply to the operation. # @param top [Integer] The maximum number of resources to return from the # operation. # @param orderby [String] The ordering expression for the results, using OData # notation. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def list_async(resource_group_name, lab_name, user_name, expand:nil, filter:nil, top:nil, orderby:nil, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name}, query_params: {'$expand' => expand,'$filter' => filter,'$top' => top,'$orderby' => orderby,'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::ResponseWithContinuationDisk.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Get disk. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Disk] operation results. # def get(resource_group_name, lab_name, user_name, name, expand:nil, custom_headers:nil) response = get_async(resource_group_name, lab_name, user_name, name, expand:expand, custom_headers:custom_headers).value! response.body unless response.nil? end # # Get disk. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def get_with_http_info(resource_group_name, lab_name, user_name, name, expand:nil, custom_headers:nil) get_async(resource_group_name, lab_name, user_name, name, expand:expand, custom_headers:custom_headers).value! end # # Get disk. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def get_async(resource_group_name, lab_name, user_name, name, expand:nil, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, 'name is nil' if name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name,'name' => name}, query_params: {'$expand' => expand,'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::Disk.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or replace an existing disk. This operation can take a while to # complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param disk [Disk] A Disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Disk] operation results. # def create_or_update(resource_group_name, lab_name, user_name, name, disk, custom_headers:nil) response = create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param disk [Disk] A Disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:nil) # Send request promise = begin_create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::Disk.mapper() parsed_response = @client.deserialize(result_mapper, parsed_response) end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method) end promise end # # Delete disk. This operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete(resource_group_name, lab_name, user_name, name, custom_headers:nil) response = delete_async(resource_group_name, lab_name, user_name, name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def delete_async(resource_group_name, lab_name, user_name, name, custom_headers:nil) # Send request promise = begin_delete_async(resource_group_name, lab_name, user_name, name, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method) end promise end # # Attach and create the lease of the disk to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param attach_disk_properties [AttachDiskProperties] Properties of the disk # to attach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def attach(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:nil) response = attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param attach_disk_properties [AttachDiskProperties] Properties of the disk # to attach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:nil) # Send request promise = begin_attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method) end promise end # # Detach and break the lease of the disk attached to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param detach_disk_properties [DetachDiskProperties] Properties of the disk # to detach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def detach(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:nil) response = detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param detach_disk_properties [DetachDiskProperties] Properties of the disk # to detach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Concurrent::Promise] promise which provides async access to http # response. # def detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:nil) # Send request promise = begin_detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method) end promise end # # Create or replace an existing disk. This operation can take a while to # complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param disk [Disk] A Disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Disk] operation results. # def begin_create_or_update(resource_group_name, lab_name, user_name, name, disk, custom_headers:nil) response = begin_create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or replace an existing disk. This operation can take a while to # complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param disk [Disk] A Disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_create_or_update_with_http_info(resource_group_name, lab_name, user_name, name, disk, custom_headers:nil) begin_create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:custom_headers).value! end # # Create or replace an existing disk. This operation can take a while to # complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param disk [Disk] A Disk. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_create_or_update_async(resource_group_name, lab_name, user_name, name, disk, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, 'name is nil' if name.nil? fail ArgumentError, 'disk is nil' if disk.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::Disk.mapper() request_content = @client.serialize(request_mapper, disk) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name,'name' => name}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:put, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 || status_code == 201 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::Disk.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end # Deserialize Response if status_code == 201 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::Disk.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Delete disk. This operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete(resource_group_name, lab_name, user_name, name, custom_headers:nil) response = begin_delete_async(resource_group_name, lab_name, user_name, name, custom_headers:custom_headers).value! nil end # # Delete disk. This operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_delete_with_http_info(resource_group_name, lab_name, user_name, name, custom_headers:nil) begin_delete_async(resource_group_name, lab_name, user_name, name, custom_headers:custom_headers).value! end # # Delete disk. This operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_delete_async(resource_group_name, lab_name, user_name, name, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, 'name is nil' if name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name,'name' => name}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:delete, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 202 || status_code == 204 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end # # Attach and create the lease of the disk to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param attach_disk_properties [AttachDiskProperties] Properties of the disk # to attach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_attach(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:nil) response = begin_attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:custom_headers).value! nil end # # Attach and create the lease of the disk to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param attach_disk_properties [AttachDiskProperties] Properties of the disk # to attach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_attach_with_http_info(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:nil) begin_attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:custom_headers).value! end # # Attach and create the lease of the disk to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param attach_disk_properties [AttachDiskProperties] Properties of the disk # to attach. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_attach_async(resource_group_name, lab_name, user_name, name, attach_disk_properties, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, 'name is nil' if name.nil? fail ArgumentError, 'attach_disk_properties is nil' if attach_disk_properties.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::AttachDiskProperties.mapper() request_content = @client.serialize(request_mapper, attach_disk_properties) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/attach' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name,'name' => name}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:post, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 || status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end # # Detach and break the lease of the disk attached to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param detach_disk_properties [DetachDiskProperties] Properties of the disk # to detach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_detach(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:nil) response = begin_detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:custom_headers).value! nil end # # Detach and break the lease of the disk attached to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param detach_disk_properties [DetachDiskProperties] Properties of the disk # to detach. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def begin_detach_with_http_info(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:nil) begin_detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:custom_headers).value! end # # Detach and break the lease of the disk attached to the virtual machine. This # operation can take a while to complete. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param name [String] The name of the disk. # @param detach_disk_properties [DetachDiskProperties] Properties of the disk # to detach. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def begin_detach_async(resource_group_name, lab_name, user_name, name, detach_disk_properties, custom_headers:nil) fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'lab_name is nil' if lab_name.nil? fail ArgumentError, 'user_name is nil' if user_name.nil? fail ArgumentError, 'name is nil' if name.nil? fail ArgumentError, 'detach_disk_properties is nil' if detach_disk_properties.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? # Serialize Request request_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::DetachDiskProperties.mapper() request_content = @client.serialize(request_mapper, detach_disk_properties) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/users/{userName}/disks/{name}/detach' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'userName' => user_name,'name' => name}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:post, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 || status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end # # List disks in a given user profile. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [ResponseWithContinuationDisk] operation results. # def list_next(next_page_link, custom_headers:nil) response = list_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # List disks in a given user profile. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def list_next_with_http_info(next_page_link, custom_headers:nil) list_next_async(next_page_link, custom_headers:custom_headers).value! end # # List disks in a given user profile. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def list_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '{nextLink}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::DevTestLabs::Mgmt::V2016_05_15::Models::ResponseWithContinuationDisk.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # List disks in a given user profile. # # @param resource_group_name [String] The name of the resource group. # @param lab_name [String] The name of the lab. # @param user_name [String] The name of the user profile. # @param expand [String] Specify the $expand query. Example: # 'properties($select=diskType)' # @param filter [String] The filter to apply to the operation. # @param top [Integer] The maximum number of resources to return from the # operation. # @param orderby [String] The ordering expression for the results, using OData # notation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [ResponseWithContinuationDisk] which provide lazy access to pages of # the response. # def list_as_lazy(resource_group_name, lab_name, user_name, expand:nil, filter:nil, top:nil, orderby:nil, custom_headers:nil) response = list_async(resource_group_name, lab_name, user_name, expand:expand, filter:filter, top:top, orderby:orderby, custom_headers:custom_headers).value! unless response.nil? page = response.body page.next_method = Proc.new do |next_page_link| list_next_async(next_page_link, custom_headers:custom_headers) end page end end end end
46.135217
173
0.697747
bb0b2c7d1294d8738b283b2f7e799049365b3fee
560
cask 'noxappplayer' do version '3.0.1.0,20200414:e34827a24f3b4c16b3d61a88eda7fc43' sha256 '77c35b79a6ee1225f15c806bcbbfbaf35de88a249e21867cd231529da74c8ade' url "https://res06.bignox.com/full/#{version.after_comma.before_colon}/#{version.after_colon}.dmg?filename=Nox_installer_for_mac_intl_#{version.before_comma}.dmg" appcast 'https://www.macupdater.net/cgi-bin/check_urls/check_url_redirect.cgi?url=https://www.bignox.com/en/download/fullPackage/mac_fullzip' name 'NoxAppPlayer' homepage 'https://www.bignox.com/' app 'NoxAppPlayer.app' end
46.666667
164
0.807143
391f3e3c71c2c872eb8cf7939cbf283e4aec2aa9
200
class ERB def initialize(String src, ~Integer safe_level = nil, ~String trim_mode = nil, String eoutvar = "_erbout") => nil; end def result(Binding binding = TOPLEVEL_BINDING) => String; end end
33.333333
120
0.725
f7182bb6f7cd7e9c722176673b55d222d4ee058a
8,843
# frozen_string_literal: true require 'nokogiri' require 'deprecation' require 'active_support' require 'assembly-objectfile/content_metadata/file' require 'assembly-objectfile/content_metadata/file_set' require 'assembly-objectfile/content_metadata/file_set_builder' require 'assembly-objectfile/content_metadata/config' require 'assembly-objectfile/content_metadata/nokogiri_builder' module Assembly SPECIAL_DPG_FOLDERS = %w[31 44 50].freeze # these special dpg folders will force any files contained in them into their own resources, regardless of filenaming convention # these are used when :bundle=>:dpg only DEPRECATED_STYLES = %i[book_with_pdf book_as_image].freeze VALID_STYLES = %i[simple_image simple_book file map document 3d webarchive-seed].freeze # This class generates content metadata for image files class ContentMetadata # Generates image content XML metadata for a repository object. # This method only produces content metadata for images # and does not depend on a specific folder structure. Note that it is class level method. # # @param [Hash] params a hash containg parameters needed to produce content metadata # :druid = required - a string of druid of the repository object's druid id (with or without 'druid:' prefix) # :objects = required - an array of Assembly::ObjectFile objects containing the list of files to add to content metadata # NOTE: if you set the :bundle option to :prebundled, you will need to pass in an array of arrays, and not a flat array, as noted below # :style = optional - a symbol containing the style of metadata to create, allowed values are # :simple_image (default), contentMetadata type="image", resource type="image" # :file, contentMetadata type="file", resource type="file" # :simple_book, contentMetadata type="book", resource type="page", but any resource which has file(s) other than an image, and also contains no images at all, will be resource type="object" # :book_with_pdf, contentMetadata type="book", resource type="page", but any resource which has any file(s) other than an image will be resource type="object" - NOTE: THIS IS DEPRECATED # :book_as_image, as simple_book, but with contentMetadata type="book", resource type="image" (same rule applies for resources with non images) - NOTE: THIS IS DEPRECATED # :map, like simple_image, but with contentMetadata type="map", resource type="image" # :3d, contentMetadata type="3d", ".obj" and other configured 3d extension files go into resource_type="3d", everything else into resource_type="file" # :webarchive-seed, contentMetadata type="webarchive-seed", resource type="image" # :bundle = optional - a symbol containing the method of bundling files into resources, allowed values are # :default = all files get their own resources (default) # :filename = files with the same filename but different extensions get bundled together in a single resource # :dpg = files representing the same image but of different mimetype that use the SULAIR DPG filenaming standard (00 vs 05) get bundled together in a single resource # :prebundlded = this option requires you to prebundled the files passed in as an array of arrays, indicating how files are bundlded into resources; this is the most flexible option since it gives you full control # :add_exif = optional - a boolean to indicate if exif data should be added (mimetype, filesize, image height/width, etc.) to each file, defaults to false and is not required if project goes through assembly # :add_file_attributes = optional - a boolean to indicate if publish/preserve/shelve/role attributes should be added using defaults or by supplied override by mime/type, defaults to false and is not required if project goes through assembly # :file_attributes = optional - a hash of file attributes by mimetype to use instead of defaults, only used if add_file_attributes is also true, # If a mimetype match is not found in your hash, the default is used (either your supplied default or the gems). # e.g. {'default'=>{:preserve=>'yes',:shelve=>'yes',:publish=>'yes'},'image/tif'=>{:preserve=>'yes',:shelve=>'no',:publish=>'no'},'application/pdf'=>{:preserve=>'yes',:shelve=>'yes',:publish=>'yes'}} # :include_root_xml = optional - a boolean to indicate if the contentMetadata returned includes a root <?xml version="1.0"?> tag, defaults to true # :preserve_common_paths = optional - When creating the file "id" attribute, content metadata uses the "relative_path" attribute of the ObjectFile objects passed in. If the "relative_path" attribute is not set, the "path" attribute is used instead, # which includes a full path to the file. If the "preserve_common_paths" parameter is set to false or left off, then the common paths of all of the ObjectFile's passed in are removed from any "path" attributes. This should turn full paths into # the relative paths that are required in content metadata file id nodes. If you do not want this behavior, set "preserve_common_paths" to true. The default is false. # :flatten_folder_structure = optional - Will remove *all* folder structure when genearting file IDs (e.g. DPG subfolders like '00','05' will be removed) when generating file IDs. This is useful if the folder structure is flattened when staging files (like for DPG). # The default is false. If set to true, will override the "preserve_common_paths" parameter. # :auto_labels = optional - Will add automated resource labels (e.g. "File 1") when labels are not provided by the user. The default is true. # See https://consul.stanford.edu/pages/viewpage.action?spaceKey=chimera&title=DOR+content+types%2C+resource+types+and+interpretive+metadata for next two settings # :reading_order = optional - only valid for simple_book, can be 'rtl' or 'ltr'. The default is 'ltr'. # Example: # Assembly::ContentMetadata.create_content_metadata(:druid=>'druid:nx288wh8889',:style=>:simple_image,:objects=>object_files,:add_file_attributes=>false) def self.create_content_metadata(druid:, objects:, auto_labels: true, add_exif: false, bundle: :default, style: :simple_image, add_file_attributes: false, file_attributes: {}, preserve_common_paths: false, flatten_folder_structure: false, include_root_xml: nil, reading_order: 'ltr') common_path = find_common_path(objects) unless preserve_common_paths # find common paths to all files provided if needed filesets = FileSetBuilder.build(bundle: bundle, objects: objects, style: style) config = Config.new(auto_labels: auto_labels, flatten_folder_structure: flatten_folder_structure, add_file_attributes: add_file_attributes, file_attributes: file_attributes, add_exif: add_exif, reading_order: reading_order, type: object_level_type(style)) builder = NokogiriBuilder.build(druid: druid, filesets: filesets, common_path: common_path, config: config) if include_root_xml == false builder.doc.root.to_xml else builder.to_xml end end def self.special_dpg_folder?(folder) SPECIAL_DPG_FOLDERS.include?(folder) end def self.find_common_path(objects) all_paths = objects.flatten.map do |obj| raise "File '#{obj.path}' not found" unless obj.file_exists? obj.path # collect all of the filenames into an array end Assembly::ObjectFile.common_path(all_paths) # find common paths to all files provided if needed end private_class_method :find_common_path def self.object_level_type(style) Deprecation.warn(self, "the style #{style} is now deprecated and should not be used. This will be removed in assembly-objectfile 2.0") if DEPRECATED_STYLES.include? style raise "Supplied style (#{style}) not valid" unless (VALID_STYLES + DEPRECATED_STYLES).include? style case style when :simple_image 'image' when :simple_book, :book_with_pdf, :book_as_image 'book' else style.to_s end end end # class end # module
74.940678
273
0.686192
03ffeca58a8509984efa5ad2035184e66ac82255
88
SpecialDelivery::Engine.routes.draw do post "/" => "events#create", :as => "root" end
22
44
0.659091
b936b553068c9662188a459bd2c36fe0380c04f5
3,863
def ensure_order_totals order.update_totals order.persist_totals end shared_context 'creates order with line item' do let!(:line_item) { create(:line_item, order: order, currency: currency) } let!(:headers) { headers_bearer } before { ensure_order_totals } end shared_context 'creates guest order with guest token' do let(:guest_token) { 'guest_token' } let!(:order) { create(:order, token: guest_token, store: store, currency: currency) } let!(:line_item) { create(:line_item, order: order, currency: currency) } let!(:headers) { headers_order_token } before { ensure_order_totals } end shared_examples 'returns valid cart JSON' do it 'returns a valid cart JSON response' do order.reload expect(json_response['data']).to be_present expect(json_response['data']).to have_id(order.id.to_s) expect(json_response['data']).to have_type('cart') expect(json_response['data']).to have_attribute(:number).with_value(order.number) expect(json_response['data']).to have_attribute(:state).with_value(order.state) expect(json_response['data']).to have_attribute(:token).with_value(order.token) expect(json_response['data']).to have_attribute(:total).with_value(order.total.to_s) expect(json_response['data']).to have_attribute(:item_total).with_value(order.item_total.to_s) expect(json_response['data']).to have_attribute(:ship_total).with_value(order.ship_total.to_s) expect(json_response['data']).to have_attribute(:adjustment_total).with_value(order.adjustment_total.to_s) expect(json_response['data']).to have_attribute(:included_tax_total).with_value(order.included_tax_total.to_s) expect(json_response['data']).to have_attribute(:additional_tax_total).with_value(order.additional_tax_total.to_s) expect(json_response['data']).to have_attribute(:display_additional_tax_total).with_value(order.display_additional_tax_total.to_s) expect(json_response['data']).to have_attribute(:display_included_tax_total).with_value(order.display_included_tax_total.to_s) expect(json_response['data']).to have_attribute(:tax_total).with_value(order.tax_total.to_s) expect(json_response['data']).to have_attribute(:currency).with_value(order.currency.to_s) expect(json_response['data']).to have_attribute(:email).with_value(order.email) expect(json_response['data']).to have_attribute(:display_item_total).with_value(order.display_item_total.to_s) expect(json_response['data']).to have_attribute(:display_ship_total).with_value(order.display_ship_total.to_s) expect(json_response['data']).to have_attribute(:display_adjustment_total).with_value(order.display_adjustment_total.to_s) expect(json_response['data']).to have_attribute(:display_tax_total).with_value(order.display_tax_total.to_s) expect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s) expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s) expect(json_response['data']).to have_attribute(:item_count).with_value(order.item_count) expect(json_response['data']).to have_attribute(:special_instructions).with_value(order.special_instructions) expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s) expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions) end end shared_examples 'no current order' do context "order doesn't exist" do before do order.destroy execute end it_behaves_like 'returns 404 HTTP status' end context 'already completed order' do before do order.update_column(:completed_at, Time.current) execute end it_behaves_like 'returns 404 HTTP status' end end
52.917808
159
0.771939
bf9b92d10c704d1a7419e7780c7e2670bf841093
1,309
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20160710103602) do create_table "orders", force: :cascade do |t| t.string "phone" t.string "name" t.string "adress" t.text "pizza" t.datetime "created_at" t.datetime "updated_at" end create_table "products", force: :cascade do |t| t.string "title" t.text "description" t.decimal "price" t.decimal "size" t.boolean "is_spicy" t.boolean "is_veg" t.boolean "is_best_offer" t.string "path_to_image" t.datetime "created_at" t.datetime "updated_at" end end
34.447368
86
0.720397
7ad08486f0f7efc44b8075d023cc47edf10adaf0
21,212
require 'test_helper' class AuthenticationSanityTest < Devise::IntegrationTest test 'home should be accessible without sign in' do visit '/' assert_response :success assert_template 'home/index' end test 'sign in as user should not authenticate admin scope' do sign_in_as_user assert warden.authenticated?(:user) refute warden.authenticated?(:admin) end test 'sign in as admin should not authenticate user scope' do sign_in_as_admin assert warden.authenticated?(:admin) refute warden.authenticated?(:user) end test 'sign in as both user and admin at same time' do sign_in_as_user sign_in_as_admin assert warden.authenticated?(:user) assert warden.authenticated?(:admin) end test 'sign out as user should not touch admin authentication if sign_out_all_scopes is false' do swap Devise, sign_out_all_scopes: false do sign_in_as_user sign_in_as_admin delete destroy_user_session_path refute warden.authenticated?(:user) assert warden.authenticated?(:admin) end end test 'sign out as admin should not touch user authentication if sign_out_all_scopes is false' do swap Devise, sign_out_all_scopes: false do sign_in_as_user sign_in_as_admin delete destroy_admin_session_path refute warden.authenticated?(:admin) assert warden.authenticated?(:user) end end test 'sign out as user should also sign out admin if sign_out_all_scopes is true' do swap Devise, sign_out_all_scopes: true do sign_in_as_user sign_in_as_admin delete destroy_user_session_path refute warden.authenticated?(:user) refute warden.authenticated?(:admin) end end test 'sign out as admin should also sign out user if sign_out_all_scopes is true' do swap Devise, sign_out_all_scopes: true do sign_in_as_user sign_in_as_admin delete destroy_admin_session_path refute warden.authenticated?(:admin) refute warden.authenticated?(:user) end end test 'not signed in as admin should not be able to access admins actions' do get admins_path assert_redirected_to new_admin_session_path refute warden.authenticated?(:admin) end test 'signed in as user should not be able to access admins actions' do sign_in_as_user assert warden.authenticated?(:user) refute warden.authenticated?(:admin) get admins_path assert_redirected_to new_admin_session_path end test 'signed in as admin should be able to access admin actions' do sign_in_as_admin assert warden.authenticated?(:admin) refute warden.authenticated?(:user) get admins_path assert_response :success assert_template 'admins/index' assert_contain 'Welcome Admin' end test 'authenticated admin should not be able to sign as admin again' do sign_in_as_admin get new_admin_session_path assert_response :redirect assert_redirected_to admin_root_path assert warden.authenticated?(:admin) end test 'authenticated admin should be able to sign out' do sign_in_as_admin assert warden.authenticated?(:admin) delete destroy_admin_session_path assert_response :redirect assert_redirected_to root_path get root_path assert_contain 'Signed out successfully' refute warden.authenticated?(:admin) end test 'unauthenticated admin set message on sign out' do delete destroy_admin_session_path assert_response :redirect assert_redirected_to root_path get root_path assert_contain 'Signed out successfully' end test 'scope uses custom failure app' do put "/en/accounts/management" assert_equal "Oops, not found", response.body assert_equal 404, response.status end end class AuthenticationRoutesRestrictions < Devise::IntegrationTest test 'not signed in should not be able to access private route (authenticate denied)' do get private_path assert_redirected_to new_admin_session_path refute warden.authenticated?(:admin) end test 'signed in as user should not be able to access private route restricted to admins (authenticate denied)' do sign_in_as_user assert warden.authenticated?(:user) refute warden.authenticated?(:admin) get private_path assert_redirected_to new_admin_session_path end test 'signed in as admin should be able to access private route restricted to admins (authenticate accepted)' do sign_in_as_admin assert warden.authenticated?(:admin) refute warden.authenticated?(:user) get private_path assert_response :success assert_template 'home/private' assert_contain 'Private!' end test 'signed in as inactive admin should not be able to access private/active route restricted to active admins (authenticate denied)' do sign_in_as_admin(active: false) assert warden.authenticated?(:admin) refute warden.authenticated?(:user) assert_raises ActionController::RoutingError do get "/private/active" end end test 'signed in as active admin should be able to access private/active route restricted to active admins (authenticate accepted)' do sign_in_as_admin(active: true) assert warden.authenticated?(:admin) refute warden.authenticated?(:user) get private_active_path assert_response :success assert_template 'home/private' assert_contain 'Private!' end test 'signed in as admin should get admin dashboard (authenticated accepted)' do sign_in_as_admin assert warden.authenticated?(:admin) refute warden.authenticated?(:user) get dashboard_path assert_response :success assert_template 'home/admin_dashboard' assert_contain 'Admin dashboard' end test 'signed in as user should get user dashboard (authenticated accepted)' do sign_in_as_user assert warden.authenticated?(:user) refute warden.authenticated?(:admin) get dashboard_path assert_response :success assert_template 'home/user_dashboard' assert_contain 'User dashboard' end test 'not signed in should get no dashboard (authenticated denied)' do assert_raises ActionController::RoutingError do get dashboard_path end end test 'signed in as inactive admin should not be able to access dashboard/active route restricted to active admins (authenticated denied)' do sign_in_as_admin(active: false) assert warden.authenticated?(:admin) refute warden.authenticated?(:user) assert_raises ActionController::RoutingError do get "/dashboard/active" end end test 'signed in as active admin should be able to access dashboard/active route restricted to active admins (authenticated accepted)' do sign_in_as_admin(active: true) assert warden.authenticated?(:admin) refute warden.authenticated?(:user) get dashboard_active_path assert_response :success assert_template 'home/admin_dashboard' assert_contain 'Admin dashboard' end test 'signed in user should not see unauthenticated page (unauthenticated denied)' do sign_in_as_user assert warden.authenticated?(:user) refute warden.authenticated?(:admin) assert_raises ActionController::RoutingError do get join_path end end test 'not signed in users should see unautheticated page (unauthenticated accepted)' do get join_path assert_response :success assert_template 'home/join' assert_contain 'Join' end end class AuthenticationRedirectTest < Devise::IntegrationTest test 'redirect from warden shows sign in or sign up message' do get admins_path warden_path = new_admin_session_path assert_redirected_to warden_path get warden_path assert_contain 'You need to sign in or sign up before continuing.' end test 'redirect to default url if no other was configured' do sign_in_as_user assert_template 'home/index' assert_nil session[:"user_return_to"] end test 'redirect to requested url after sign in' do get users_path assert_redirected_to new_user_session_path assert_equal users_path, session[:"user_return_to"] follow_redirect! sign_in_as_user visit: false assert_current_url '/users' assert_nil session[:"user_return_to"] end test 'redirect to last requested url overwriting the stored return_to option' do get expire_user_path(create_user) assert_redirected_to new_user_session_path assert_equal expire_user_path(create_user), session[:"user_return_to"] get users_path assert_redirected_to new_user_session_path assert_equal users_path, session[:"user_return_to"] follow_redirect! sign_in_as_user visit: false assert_current_url '/users' assert_nil session[:"user_return_to"] end test 'xml http requests does not store urls for redirect' do get users_path, headers: { 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest' } assert_equal 401, response.status assert_nil session[:"user_return_to"] end test 'redirect to configured home path for a given scope after sign in' do sign_in_as_admin assert_equal "/admin_area/home", @request.path end test 'require_no_authentication should set the already_authenticated flash message' do sign_in_as_user visit new_user_session_path assert_equal flash[:alert], I18n.t("devise.failure.already_authenticated") end end class AuthenticationSessionTest < Devise::IntegrationTest test 'destroyed account is signed out' do sign_in_as_user get '/users' User.destroy_all get '/users' assert_redirected_to new_user_session_path end test 'refreshes _csrf_token' do ApplicationController.allow_forgery_protection = true begin get new_user_session_path token = request.session[:_csrf_token] sign_in_as_user assert_not_equal request.session[:_csrf_token], token ensure ApplicationController.allow_forgery_protection = false end end test 'allows session to be set for a given scope' do sign_in_as_user get '/users' assert_equal "Cart", @controller.user_session[:cart] end test 'session id is changed on sign in' do get '/users' session_id = request.session["session_id"] get '/users' assert_equal session_id, request.session["session_id"] sign_in_as_user assert_not_equal session_id, request.session["session_id"] end end class AuthenticationWithScopedViewsTest < Devise::IntegrationTest test 'renders the scoped view if turned on and view is available' do swap Devise, scoped_views: true do assert_raise Webrat::NotFoundError do sign_in_as_user end assert_match %r{Special user view}, response.body end end test 'renders the scoped view if turned on in an specific controller' do begin Devise::SessionsController.scoped_views = true assert_raise Webrat::NotFoundError do sign_in_as_user end assert_match %r{Special user view}, response.body assert !Devise::PasswordsController.scoped_views? ensure Devise::SessionsController.send :remove_instance_variable, :@scoped_views end end test 'does not render the scoped view if turned off' do swap Devise, scoped_views: false do assert_nothing_raised do sign_in_as_user end end end test 'does not render the scoped view if not available' do swap Devise, scoped_views: true do assert_nothing_raised do sign_in_as_admin end end end end class AuthenticationOthersTest < Devise::IntegrationTest test 'handles unverified requests gets rid of caches' do swap ApplicationController, allow_forgery_protection: true do post exhibit_user_url(1) refute warden.authenticated?(:user) sign_in_as_user assert warden.authenticated?(:user) post exhibit_user_url(1) refute warden.authenticated?(:user) assert_equal "User is not authenticated", response.body end end test 'uses the custom controller with the custom controller view' do get '/admin_area/sign_in' assert_contain 'Log in' assert_contain 'Welcome to "admins/sessions" controller!' assert_contain 'Welcome to "sessions/new" view!' end test 'render 404 on roles without routes' do assert_raise ActionController::RoutingError do get '/admin_area/password/new' end end test 'does not intercept Rails 401 responses' do get '/unauthenticated' assert_equal 401, response.status end test 'render 404 on roles without mapping' do assert_raise AbstractController::ActionNotFound do get '/sign_in' end end test 'sign in with script name' do assert_nothing_raised do get new_user_session_path, headers: { "SCRIPT_NAME" => "/omg" } fill_in "email", with: "[email protected]" end end test 'sign in stub in xml format' do get new_user_session_path(format: 'xml') assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body assert_match %r{<user>.*</user>}m, response.body assert_match '<email></email>', response.body assert_match '<password nil="true"', response.body end test 'sign in stub in json format' do get new_user_session_path(format: 'json') assert_match '{"user":{', response.body assert_match '"email":""', response.body assert_match '"password":null', response.body end test 'sign in stub in json with non attribute key' do swap Devise, authentication_keys: [:other_key] do get new_user_session_path(format: 'json') assert_match '{"user":{', response.body assert_match '"other_key":null', response.body assert_match '"password":null', response.body end end test 'uses the mapping from router' do sign_in_as_user visit: "/as/sign_in" assert warden.authenticated?(:user) refute warden.authenticated?(:admin) end test 'sign in with xml format returns xml response' do create_user post user_session_path(format: 'xml'), params: { user: {email: "[email protected]", password: '12345678'} } assert_response :success assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>) end test 'sign in with xml format is idempotent' do get new_user_session_path(format: 'xml') assert_response :success create_user post user_session_path(format: 'xml'), params: { user: {email: "[email protected]", password: '12345678'} } assert_response :success get new_user_session_path(format: 'xml') assert_response :success post user_session_path(format: 'xml'), params: { user: {email: "[email protected]", password: '12345678'} } assert_response :success assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>) end test 'sign out with html redirects' do sign_in_as_user delete destroy_user_session_path assert_response :redirect assert_current_url '/' sign_in_as_user delete destroy_user_session_path(format: 'html') assert_response :redirect assert_current_url '/' end test 'sign out with xml format returns no content' do sign_in_as_user delete destroy_user_session_path(format: 'xml') assert_response :no_content refute warden.authenticated?(:user) end test 'sign out with json format returns no content' do sign_in_as_user delete destroy_user_session_path(format: 'json') assert_response :no_content refute warden.authenticated?(:user) end test 'sign out with non-navigational format via XHR does not redirect' do swap Devise, navigational_formats: ['*/*', :html] do sign_in_as_admin get destroy_sign_out_via_get_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*. assert_response :no_content refute warden.authenticated?(:user) end end # Belt and braces ... Perhaps this test is not necessary? test 'sign out with navigational format via XHR does redirect' do swap Devise, navigational_formats: ['*/*', :html] do sign_in_as_user delete destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" } assert_response :redirect refute warden.authenticated?(:user) end end end class AuthenticationKeysTest < Devise::IntegrationTest test 'missing authentication keys cause authentication to abort' do swap Devise, authentication_keys: [:subdomain] do sign_in_as_user assert_contain "Invalid Subdomain or password." refute warden.authenticated?(:user) end end test 'missing authentication keys cause authentication to abort unless marked as not required' do swap Devise, authentication_keys: { email: true, subdomain: false } do sign_in_as_user assert warden.authenticated?(:user) end end end class AuthenticationRequestKeysTest < Devise::IntegrationTest test 'request keys are used on authentication' do host! 'foo.bar.baz' swap Devise, request_keys: [:subdomain] do User.expects(:find_for_authentication).with(subdomain: 'foo', email: '[email protected]').returns(create_user) sign_in_as_user assert warden.authenticated?(:user) end end test 'invalid request keys raises NoMethodError' do swap Devise, request_keys: [:unknown_method] do assert_raise NoMethodError do sign_in_as_user end refute warden.authenticated?(:user) end end test 'blank request keys cause authentication to abort' do host! 'test.com' swap Devise, request_keys: [:subdomain] do sign_in_as_user assert_contain "Invalid Email or password." refute warden.authenticated?(:user) end end test 'blank request keys cause authentication to abort unless if marked as not required' do host! 'test.com' swap Devise, request_keys: { subdomain: false } do sign_in_as_user assert warden.authenticated?(:user) end end end class AuthenticationSignOutViaTest < Devise::IntegrationTest def sign_in!(scope) sign_in_as_admin(visit: send("new_#{scope}_session_path")) assert warden.authenticated?(scope) end test 'allow sign out via delete when sign_out_via provides only delete' do sign_in!(:sign_out_via_delete) delete destroy_sign_out_via_delete_session_path refute warden.authenticated?(:sign_out_via_delete) end test 'do not allow sign out via get when sign_out_via provides only delete' do sign_in!(:sign_out_via_delete) assert_raise ActionController::RoutingError do get destroy_sign_out_via_delete_session_path end assert warden.authenticated?(:sign_out_via_delete) end test 'allow sign out via post when sign_out_via provides only post' do sign_in!(:sign_out_via_post) post destroy_sign_out_via_post_session_path refute warden.authenticated?(:sign_out_via_post) end test 'do not allow sign out via get when sign_out_via provides only post' do sign_in!(:sign_out_via_post) assert_raise ActionController::RoutingError do get destroy_sign_out_via_delete_session_path end assert warden.authenticated?(:sign_out_via_post) end test 'allow sign out via delete when sign_out_via provides delete and post' do sign_in!(:sign_out_via_delete_or_post) delete destroy_sign_out_via_delete_or_post_session_path refute warden.authenticated?(:sign_out_via_delete_or_post) end test 'allow sign out via post when sign_out_via provides delete and post' do sign_in!(:sign_out_via_delete_or_post) post destroy_sign_out_via_delete_or_post_session_path refute warden.authenticated?(:sign_out_via_delete_or_post) end test 'do not allow sign out via get when sign_out_via provides delete and post' do sign_in!(:sign_out_via_delete_or_post) assert_raise ActionController::RoutingError do get destroy_sign_out_via_delete_or_post_session_path end assert warden.authenticated?(:sign_out_via_delete_or_post) end end class DoubleAuthenticationRedirectTest < Devise::IntegrationTest test 'signed in as user redirects when visiting user sign in page' do sign_in_as_user get new_user_session_path(format: :html) assert_redirected_to '/' end test 'signed in as admin redirects when visiting admin sign in page' do sign_in_as_admin get new_admin_session_path(format: :html) assert_redirected_to '/admin_area/home' end test 'signed in as both user and admin redirects when visiting admin sign in page' do sign_in_as_user sign_in_as_admin get new_user_session_path(format: :html) assert_redirected_to '/' get new_admin_session_path(format: :html) assert_redirected_to '/admin_area/home' end end class DoubleSignOutRedirectTest < Devise::IntegrationTest test 'sign out after already having signed out redirects to sign in' do sign_in_as_user post destroy_sign_out_via_delete_or_post_session_path get root_path assert_contain 'Signed out successfully.' post destroy_sign_out_via_delete_or_post_session_path get root_path assert_contain 'Signed out successfully.' end end
30.346209
184
0.738497
e2de78b8fe99e235ac9e1324041a8386d4921426
857
# WARNING ABOUT GENERATED CODE # # This file is generated. See the contributing guide for more information: # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md # # WARNING ABOUT GENERATED CODE # Shared Smoke Test Definitions Given(/I create a client in region '(.*?)'/) do |region| @regional_client = Aws::ApplicationAutoScaling::Client.new(region: region) end When(/I call the operation '(.*?)' with params:/) do |operation, params| opts = JSON.parse(params, symbolize_names: true) begin @regional_client.send(operation.to_sym, opts) @operation_raised_error = false rescue StandardError @operation_raised_error = true end end Then(/I expect an error was raised/) do expect(@operation_raised_error).to be_truthy end Then(/I expect an error was not raised/) do expect(@operation_raised_error).not_to be_truthy end
28.566667
76
0.749125
ff7bacf42f1c6b61d45c4625303130af1fe8609e
14,558
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ # # Copyright (c) 2016, Electric Power Research Institute (EPRI) # All rights reserved. # # OpenADR ("this software") is licensed under BSD 3-Clause license. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # * Neither the name of EPRI nor the names of its contributors may # be used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE. # # This EPRI software incorporates work covered by the following copyright and permission # notices. You may not use these works except in compliance with their respective # licenses, which are provided below. # # These works are provided by the copyright holders and contributors "as is" and any express or # implied warranties, including, but not limited to, the implied warranties of merchantability # and fitness for a particular purpose are disclaimed. # ######################################################################################### # MIT Licensed Libraries ######################################################################################### # # * actionmailer 3.2.12 (http://www.rubyonrails.org) - Email composition, delivery, and receiving framework (part of Rails). # * actionpack 3.2.12 (http://www.rubyonrails.org) - Web-flow and rendering framework putting the VC in MVC (part of Rails). # * activemodel 3.2.12 (http://www.rubyonrails.org) - A toolkit for building modeling frameworks (part of Rails). # * activerecord 3.2.12 (http://www.rubyonrails.org) - Object-relational mapper framework (part of Rails). # * activeresource 3.2.12 (http://www.rubyonrails.org) - REST modeling framework (part of Rails). # * activesupport 3.2.12 (http://www.rubyonrails.org) - A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. # * arel 3.0.2 (http://github.com/rails/arel) - Arel is a SQL AST manager for Ruby # * bootstrap-sass 3.1.1.0 (https://github.com/twbs/bootstrap-sass) - Twitter's Bootstrap, converted to Sass and ready to drop into Rails or Compass # * builder 3.0.4 (http://onestepback.org) - Builders for MarkUp. # * bundler 1.12.5 (http://bundler.io) - The best way to manage your application's dependencies # * capybara 2.4.4 (http://github.com/jnicklas/capybara) - Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb # * coffee-rails 3.2.2 () - Coffee Script adapter for the Rails asset pipeline. # * coffee-script-source 1.6.3 (http://jashkenas.github.com/coffee-script/) - The CoffeeScript Compiler # * docile 1.1.5 (https://ms-ati.github.io/docile/) - Docile keeps your Ruby DSLs tame and well-behaved # * edn 1.0.0 () - 'edn implements a reader for Extensible Data Notation by Rich Hickey.' # * erubis 2.7.0 (http://www.kuwata-lab.com/erubis/) - a fast and extensible eRuby implementation which supports multi-language # * execjs 1.4.0 (https://github.com/sstephenson/execjs) - Run JavaScript code from Ruby # * factory_girl 4.5.0 (https://github.com/thoughtbot/factory_girl) - factory_girl provides a framework and DSL for defining and using model instance factories. # * factory_girl_rails 4.5.0 (http://github.com/thoughtbot/factory_girl_rails) - factory_girl_rails provides integration between factory_girl and rails 3 # * gem-licenses 0.1.2 (http://github.com/dblock/gem-licenses) - List all gem licenses. # * hike 1.2.3 (http://github.com/sstephenson/hike) - Find files in a set of paths # * i18n 0.6.5 (http://github.com/svenfuchs/i18n) - New wave Internationalization support for Ruby # * jdbc-postgresql 9.2.1000 (https://github.com/rosenfeld/jdbc-postgresql) - PostgresSQL jdbc driver for JRuby # * journey 1.0.4 (http://github.com/rails/journey) - Journey is a router # * jquery-rails 3.0.4 (http://rubygems.org/gems/jquery-rails) - Use jQuery with Rails 3 # * json-schema 2.6.2 (http://github.com/ruby-json-schema/json-schema/tree/master) - Ruby JSON Schema Validator # * mail 2.4.4 (http://github.com/mikel/mail) - Mail provides a nice Ruby DSL for making, sending and reading emails. # * metaclass 0.0.4 (http://github.com/floehopper/metaclass) - Adds a metaclass method to all Ruby objects # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type # * mocha 1.1.0 (http://gofreerange.com/mocha/docs) - Mocking and stubbing library # * multi_json 1.7.9 (http://github.com/intridea/multi_json) - A common interface to multiple JSON libraries. # * nokogiri 1.6.5 (http://nokogiri.org) - Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser # * polyglot 0.3.3 (http://github.com/cjheath/polyglot) - Augment 'require' to load non-Ruby file types # * rack-test 0.6.2 (http://github.com/brynary/rack-test) - Simple testing API built on Rack # * railties 3.2.12 (http://www.rubyonrails.org) - Tools for creating, working with, and running Rails applications. # * rake 10.1.0 (http://rake.rubyforge.org) - Ruby based make-like utility. # * rspec-core 2.14.3 (http://github.com/rspec/rspec-core) - rspec-core-2.14.3 # * rspec-expectations 2.14.0 (http://github.com/rspec/rspec-expectations) - rspec-expectations-2.14.0 # * rspec-mocks 2.14.1 (http://github.com/rspec/rspec-mocks) - rspec-mocks-2.14.1 # * rspec-rails 2.14.0 (http://github.com/rspec/rspec-rails) - rspec-rails-2.14.0 # * sass 3.2.9 (http://sass-lang.com/) - A powerful but elegant CSS compiler that makes CSS fun again. # * sass-rails 3.2.6 () - Sass adapter for the Rails asset pipeline. # * simplecov 0.9.0 (http://github.com/colszowka/simplecov) - Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites # * spork 1.0.0rc3 (http://github.com/sporkrb/spork) - spork # * therubyrhino 2.0.2 (http://github.com/cowboyd/therubyrhino) - Embed the Rhino JavaScript interpreter into JRuby # * thor 0.18.1 (http://whatisthor.com/) - A scripting framework that replaces rake, sake and rubigen # * tilt 1.4.1 (http://github.com/rtomayko/tilt/) - Generic interface to multiple Ruby template engines # * treetop 1.4.14 (https://github.com/cjheath/treetop) - A Ruby-based text parsing and interpretation DSL # * uglifier 2.1.2 (http://github.com/lautis/uglifier) - Ruby wrapper for UglifyJS JavaScript compressor # * xpath 2.0.0 (http://github.com/jnicklas/xpath) - Generate XPath expressions from Ruby # * blankslate 2.1.2.4 (http://github.com/masover/blankslate) - BlankSlate extracted from Builder. # * bourbon 3.1.8 (https://github.com/thoughtbot/bourbon) - Bourbon Sass Mixins using SCSS syntax. # * coffee-script 2.2.0 (http://github.com/josh/ruby-coffee-script) - Ruby CoffeeScript Compiler # * diff-lcs 1.2.4 (http://diff-lcs.rubyforge.org/) - Diff::LCS computes the difference between two Enumerable sequences using the McIlroy-Hunt longest common subsequence (LCS) algorithm # * jquery-ui-rails 4.0.3 (https://github.com/joliss/jquery-ui-rails) - jQuery UI packaged for the Rails asset pipeline # * parslet 1.4.0 (http://kschiess.github.com/parslet) - Parser construction library with great error reporting in Ruby. # * rack 1.4.5 (http://rack.github.com/) - a modular Ruby webserver interface # * rack-cache 1.2 (http://tomayko.com/src/rack-cache/) - HTTP Caching for Rack # * rack-ssl 1.3.3 (https://github.com/josh/rack-ssl) - Force SSL/TLS in your app. # * rails 3.2.12 (http://www.rubyonrails.org) - Full-stack web application framework. # * simplecov-html 0.8.0 (https://github.com/colszowka/simplecov-html) - Default HTML formatter for SimpleCov code coverage tool for ruby 1.9+ # * tzinfo 0.3.37 (http://tzinfo.rubyforge.org/) - Daylight-savings aware timezone library # * warbler 1.4.0.beta1 (http://caldersphere.rubyforge.org/warbler) - Warbler chirpily constructs .war files of your Rails applications. # ######################################################################################### # BSD Licensed Libraries ######################################################################################### # # * activerecord-jdbc-adapter 1.2.9.1 (https://github.com/jruby/activerecord-jdbc-adapter) - Copyright (c) 2006-2012 Nick Sieger <[email protected]>, Copyright (c) 2006-2008 Ola Bini <[email protected]> # * jdbc-postgres 9.2.1004 (https://github.com/jruby/activerecord-jdbc-adapter) - Copyright (c) 1997-2011, PostgreSQL Global Development Group # * d3js 3.5.16 (https://d3js.org/) Copyright (c) 2015 Mike Bostock # ######################################################################################### # Ruby Licensed Libraries ######################################################################################### # # * json 1.8.0 (http://json-jruby.rubyforge.org/) - JSON implementation for JRuby # * rubyzip 0.9.9 (http://github.com/aussiegeek/rubyzip) - rubyzip is a ruby module for reading and writing zip files # * httpclient 2.3.4.1 (http://github.com/nahi/httpclient) - gives something like the functionality of libwww-perl (LWP) in Ruby # * test-unit 2.5.5 (http://test-unit.rubyforge.org/) - test-unit - Improved version of Test::Unit bundled in Ruby 1.8.x. # ######################################################################################### # Public domain - creative commons Licensed Libraries ######################################################################################### # # * torquebox 3.1.2 (http://torquebox.org/) - TorqueBox Gem # * torquebox-cache 3.1.2 (http://torquebox.org/) - TorqueBox Cache Gem # * torquebox-configure 3.1.2 (http://torquebox.org/) - TorqueBox Configure Gem # * torquebox-core 3.1.2 (http://torquebox.org/) - TorqueBox Core Gem # * torquebox-messaging 3.1.2 (http://torquebox.org/) - TorqueBox Messaging Client # * torquebox-naming 3.1.2 (http://torquebox.org/) - TorqueBox Naming Client # * torquebox-rake-support 3.1.2 (http://torquebox.org/) - TorqueBox Rake Support # * torquebox-security 3.1.2 (http://torquebox.org/) - TorqueBox Security Gem # * torquebox-server 3.1.2 (http://torquebox.org/) - TorqueBox Server Gem # * torquebox-stomp 3.1.2 (http://torquebox.org/) - TorqueBox STOMP Support # * torquebox-transactions 3.1.2 (http://torquebox.org/) - TorqueBox Transactions Gem # * torquebox-web 3.1.2 (http://torquebox.org/) - TorqueBox Web Gem # ######################################################################################### # Apache Licensed Libraries ######################################################################################### # # * addressable 2.3.8 (https://github.com/sporkmonger/addressable) - URI Implementation # * bcrypt-ruby 3.0.1 (http://bcrypt-ruby.rubyforge.org) - OpenBSD's bcrypt() password hashing algorithm. # * database_cleaner 1.4.0 (http://github.com/bmabey/database_cleaner) - Strategies for cleaning databases. Can be used to ensure a clean state for testing. # * annotate 2.5.0 (http://github.com/ctran/annotate_models) - Annotates Rails Models, routes, fixtures, and others based on the database schema. # * nvd3 1.8.4 (http://nvd3.org/) Copeyright (c) 2014 Novus Partners - chart library based on d3js # * smack 3.3.1 (https://www.igniterealtime.org/projects/smack/) - XMPP library # ######################################################################################### # LGPL ######################################################################################### # # * jruby-1.7.4 # * jruby-jars 1.7.4 (http://github.com/jruby/jruby/tree/master/gem/jruby-jars) - The core JRuby code and the JRuby stdlib as jar # ** JRuby is tri-licensed GPL, LGPL, and EPL. # ######################################################################################### # MPL Licensed Libraries ######################################################################################### # # * therubyrhino_jar 1.7.4 (http://github.com/cowboyd/therubyrhino) - Rhino's jars packed for therubyrhino # ######################################################################################### # Artistic 2.0 # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type # ######################################################################################### # ######################################################################################### # GPL-2 ######################################################################################### # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type # ######################################################################################### # No License Given ######################################################################################### # # * spork-testunit 0.0.8 (http://github.com/timcharper/spork-testunit) - spork-testunit # * sprockets 2.2.2 (http://getsprockets.org/) - Rack-based asset packaging system # #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ namespace :db do namespace :seed do desc "Load seed data from all files in known local directory" task :load_local_seeds => :environment do Dir['../local_oadr_data_seeds/*.rb'].each do |filename| load(filename) if File.exist?(filename) end end end end
73.155779
206
0.636763
3384b94ad2f42354f175ca0f082a35ec912dd061
498
Shindo.tests('Fog::Compute[:vsphere] | hosts collection', ['vsphere']) do compute = Fog::Compute[:vsphere] cluster = compute.datacenters.first.clusters.get('Solutionscluster') hosts = cluster.hosts tests('The hosts collection') do test('should not be empty') { !hosts.empty? } test('should be a kind of Fog::Vsphere::Compute::Hosts') { hosts.is_a? Fog::Vsphere::Compute::Hosts } test('should get hosts') { hosts.get('host1.example.com').name == 'host1.example.com' } end end
41.5
105
0.688755
e2e6926253b877054d50846f2d1127df11e923d4
42
class SparseArray VERSION = "0.0.6" end
10.5
19
0.690476
79dced9b698ab5ed6dcfdaf2e00a841bda9d0966
356
module SpreeProductImport module_function # Returns the version of the currently loaded SpreeProductImport as a # <tt>Gem::Version</tt>. def version Gem::Version.new VERSION::STRING end module VERSION MAJOR = 0 MINOR = 0 TINY = 1 PRE = 'alpha'.freeze STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end end
18.736842
71
0.657303
2684e9e468e13b8a2c54d2d68a08d42bbbc2a214
4,453
class GraphTool < Formula include Language::Python::Virtualenv desc "Efficient network analysis for Python 3" homepage "https://graph-tool.skewed.de/" url "https://downloads.skewed.de/graph-tool/graph-tool-2.27.tar.bz2" sha256 "4740c69720dfbebf8fb3e77057b3e6a257ccf0432cdaf7345f873247390e4313" revision 5 bottle do sha256 "fd6dec6e0fe1b4992600c37dfc2c3ef01faf7a5ba69a877bd6d442a14f4da8ce" => :mojave sha256 "a7e35d2fc82540ee670f601079de6eeb52f95f16386eb67dff725d07f166dac6" => :sierra end depends_on "pkg-config" => :build depends_on "boost" depends_on "boost-python3" depends_on "cairomm" depends_on "cgal" depends_on "google-sparsehash" depends_on "gtk+3" depends_on "librsvg" depends_on :macos => :el_capitan # needs thread-local storage depends_on "numpy" depends_on "py3cairo" depends_on "pygobject3" depends_on "python" depends_on "scipy" resource "Cycler" do url "https://files.pythonhosted.org/packages/c2/4b/137dea450d6e1e3d474e1d873cd1d4f7d3beed7e0dc973b06e8e10d32488/cycler-0.10.0.tar.gz" sha256 "cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8" end resource "kiwisolver" do url "https://files.pythonhosted.org/packages/31/60/494fcce70d60a598c32ee00e71542e52e27c978e5f8219fae0d4ac6e2864/kiwisolver-1.0.1.tar.gz" sha256 "ce3be5d520b4d2c3e5eeb4cd2ef62b9b9ab8ac6b6fedbaa0e39cdb6f50644278" end resource "matplotlib" do url "https://files.pythonhosted.org/packages/ec/ed/46b835da53b7ed05bd4c6cae293f13ec26e877d2e490a53a709915a9dcb7/matplotlib-2.2.2.tar.gz" sha256 "4dc7ef528aad21f22be85e95725234c5178c0f938e2228ca76640e5e84d8cde8" end resource "pyparsing" do url "https://files.pythonhosted.org/packages/3c/ec/a94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c/pyparsing-2.2.0.tar.gz" sha256 "0832bcf47acd283788593e7a0f542407bd9550a55a8a8435214a1960e04bcb04" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/a0/b0/a4e3241d2dee665fea11baec21389aec6886655cd4db7647ddf96c3fad15/python-dateutil-2.7.3.tar.gz" sha256 "e27001de32f627c22380a688bcc43ce83504a7bc5da472209b4c70f02829f0b8" end resource "pytz" do url "https://files.pythonhosted.org/packages/10/76/52efda4ef98e7544321fd8d5d512e11739c1df18b0649551aeccfb1c8376/pytz-2018.4.tar.gz" sha256 "c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749" end resource "six" do url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz" sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9" end # Remove for > 2.27 # Upstream commit from 3 Jul 2018 "Fix incompatibility with Python 3.7" patch do url "https://git.skewed.de/count0/graph-tool/commit/0407f41a.diff" sha256 "94559544ad95753a13ee701c02af706c8b296c54af2c1706520ec96e24aa6d39" end # Remove for > 2.27 # Upstream commit from 3 Oct 2018 "Fix compilation with CGAL 4.13" patch do url "https://git.skewed.de/count0/graph-tool/commit/aa39e4a6.diff" sha256 "5a4ea386342c2de9422da5b07dd4272d47d2cdbba99d9b258bff65a69da562c1" end def install # Work around "error: no member named 'signbit' in the global namespace" ENV["SDKROOT"] = MacOS.sdk_path if MacOS.version == :high_sierra xy = Language::Python.major_minor_version "python3" venv = virtualenv_create(libexec, "python3") resources.each do |r| venv.pip_install_and_link r end args = %W[ --disable-debug --disable-dependency-tracking --prefix=#{prefix} PYTHON=python3 PYTHON_LIBS=-undefined\ dynamic_lookup --with-python-module-path=#{lib}/python#{xy}/site-packages --with-boost-python=boost_python#{xy.to_s.delete(".")}-mt ] args << "--with-expat=#{MacOS.sdk_path}/usr" if MacOS.sdk_path_if_needed system "./configure", *args system "make", "install" site_packages = "lib/python#{xy}/site-packages" pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n" (prefix/site_packages/"homebrew-graph-tool.pth").write pth_contents end test do (testpath/"test.py").write <<~EOS import graph_tool as gt g = gt.Graph() v1 = g.add_vertex() v2 = g.add_vertex() e = g.add_edge(v1, v2) assert g.num_edges() == 1 assert g.num_vertices() == 2 EOS system "python3", "test.py" end end
36.5
145
0.75567
f85b541d4770327606215be1db68d548a60c5790
992
module Idv class JurisdictionFailurePresenter < FailurePresenter attr_reader :jurisdiction, :reason, :view_context delegate :account_path, :decorated_session, :idv_jurisdiction_path, :link_to, :state_name_for_abbrev, :t, to: :view_context def initialize(jurisdiction:, reason:, view_context:) super(:failure) @jurisdiction = jurisdiction @reason = reason @view_context = view_context end def title t("idv.titles.#{reason}", **i18n_args) end def header t("idv.titles.#{reason}", **i18n_args) end def description t("idv.messages.jurisdiction.#{reason}_failure", **i18n_args) end def message nil end def next_steps [] end def display_back_to_account? true end private def i18n_args jurisdiction ? { state: state_name_for_abbrev(jurisdiction) } : {} end end end
19.45098
72
0.602823
117de7d1847235ee8ab05e4eb7fb8bb0a7bd73f6
1,426
# encoding: UTF-8 Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'solidus_events_tracker' s.version = '2.1.1' s.summary = 'Tracks user activity for reporting.' s.description = 'Tracks user activity and events on the server side. Use Solidus Admin Insights to build reports of user activity.' s.required_ruby_version = '>= 2.1.0' s.author = ["Nimish Mehta", "Tanmay Sinha", "+ Vinsol Team"] s.email = '[email protected]' s.homepage = 'http://vinsol.com' s.license = 'BSD-3' s.files = `git ls-files`.split("\n") # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.require_path = 'lib' s.requirements << 'none' solidus_version = '~> 2.1' s.add_dependency 'solidus_core', solidus_version s.add_development_dependency 'shoulda-matchers', '~> 2.6.2' s.add_development_dependency 'rspec-activemodel-mocks' s.add_development_dependency 'capybara', '~> 2.5' s.add_development_dependency 'coffee-rails' s.add_development_dependency 'database_cleaner' s.add_development_dependency 'factory_girl', '~> 4.5' s.add_development_dependency 'ffaker', '~> 2.2.0' s.add_development_dependency 'rspec-rails', '~> 3.4' s.add_development_dependency 'sass-rails', '~> 5.0.0' s.add_development_dependency 'selenium-webdriver' s.add_development_dependency 'simplecov' s.add_development_dependency 'sqlite3' end
37.526316
133
0.698457
260100836dfdca757d51eb9288852cfc2ff60cae
888
module Listeners class CensusEmployeeListener < ::Acapi::Amqp::Client def initialize(ch, q) super(ch, q) @controller = Events::CensusEmployeesController.new end def self.queue_name config = Rails.application.config.acapi "#{config.hbx_id}.#{config.environment_name}.q.#{config.app_id}.census_employee_listener" end def on_message(delivery_info, properties, payload) @controller.resource(connection,delivery_info, properties, payload) channel.acknowledge(delivery_info.delivery_tag, false) end def self.run conn = Bunny.new(Rails.application.config.acapi.remote_broker_uri, :heartbeat => 15) conn.start ch = conn.create_channel ch.prefetch(1) q = ch.queue(queue_name, :durable => true) self.new(ch, q).subscribe(:block => true, :manual_ack => true) conn.close end end end
30.62069
95
0.686937
8747d23d65a03f7cdb028644a56d85e22f743f23
422
module Pressletter module Shell # This namespace is for the minimal interoperable imperative code end module Core # This namespace is for the private functional code end module Values # This namespace is for behavioral-less values which # => serve as messages between core & shell and between shells. end end Dir[File.join(File.dirname(__FILE__), "**", "*.rb")].each {|file| require file }
24.823529
80
0.7109
e9bc4ef2a2e11a9d0fb7929d59991ea7fd07ba01
119
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require "yard/minitest_example" require "minitest/autorun"
23.8
58
0.764706
18fe2466dae69f297f9a3f89a1502a1a888a3f20
850
# Licensed to Elasticsearch B.V. under one or more contributor # license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright # ownership. Elasticsearch B.V. 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. module Elasticsearch module Persistence VERSION = '7.2.1' end end
36.956522
63
0.768235
285e5e43ff71acb8f94a10dfd20c03919e9b105b
823
# # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| s.name = 'multi_image_picker' s.version = '4.4.1' s.summary = 'Multi image picker' s.description = <<-DESC A new flutter plugin project. DESC s.homepage = 'https://github.com/Sh1d0w/multi_image_picker' s.license = { :file => '../LICENSE' } s.author = { 'Radoslav Vitanov' => '[email protected]' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.dependency 'BSImagePicker', '~> 2.10.0' s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" } s.swift_version = '5.0' s.ios.deployment_target = '9.0' end
32.92
83
0.579587
7aae63dd0e022359c195e8d3132a002113552887
525
# -*- encoding : utf-8 -*- require 'spec_helper' describe OCRSDK::AbstractEntity do before do OCRSDK.setup do |config| config.application_id = 'meow' config.password = 'purr' end end it "should initialize and prepare url" do OCRSDK::AbstractEntity.new.instance_eval { @url }.to_s.should_not be_empty end it "should prepare url correctly" do OCRSDK::AbstractEntity.new.instance_eval { prepare_url 'meow!', "'pew'" }.to_s.should == "http://meow%21:%27pew%[email protected]" end end
26.25
136
0.689524
ab69775a826b28fba4c8bcc2217f690d5cb08c36
731
RSpec.describe MarchHare::Exchange do let(:connection) { MarchHare.connect } after :each do connection.close end it "unbinds two existing exchanges" do ch = connection.create_channel source = ch.fanout("bunny.exchanges.source#{rand}") destination = ch.fanout("bunny.exchanges.destination#{rand}") queue = ch.queue("", :exclusive => true) queue.bind(destination) destination.bind(source) source.publish("") sleep 0.5 expect(queue.message_count).to eq(1) queue.pop(:ack => true) destination.unbind(source) source.publish("") sleep 0.5 expect(queue.message_count).to eq(0) source.delete destination.delete ch.close end end
20.885714
65
0.652531
e8c961486e78f58d21679ff5bf7c3933225d59d4
529
# frozen_string_literal: true if Gem::Specification.find_all_by_name('kamaze-project').any? require 'kamaze/project' self.tap do |main| Kamaze.project do |project| project.subject = Class.new { const_set(:VERSION, main.image.version) } project.name = image.name # noinspection RubyLiteralArrayInspection project.tasks = [ 'cs:correct', 'cs:control', 'cs:pre-commit', 'misc:gitignore', 'shell', 'test', 'version:edit', ] end.load! end end
25.190476
77
0.621928
1c72e9e49badb09a52e40ee3a4108c47630335ba
1,142
require File.dirname(__FILE__) + '/../test_helper' class BannedIpControllerTest < ActionController::TestCase fixtures :users def setup @banned_ip = create_banned_ip("1.2.3.4") end def test_new get :new, {}, {:user_id => 1} assert_response :success end def test_create post :create, {:banned_ip => {:ip_addr => "5.6.7.8", :reason => "test"}}, {:user_id => 1} assert(BannedIp.is_banned?("5.6.7.8")) end def test_index get :index, {}, {:user_id => 1} assert_response :success end def test_search_users get :search_users, {}, {:user_id => 1} assert_response :success wiki_page = create_wiki() get :search_users, {:user_ids => "1"}, {:user_id => 1} assert_response :success end def test_search_ip_addrs get :search_ip_addrs, {}, {:user_id => 1} assert_response :success wiki_page = create_wiki() get :search_ip_addrs, {:ip_addrs => "127.0.0.1"}, {:user_id => 1} assert_response :success end def test_destroy post :destroy, {:id => @banned_ip.id}, {:user_id => 1} assert(!BannedIp.is_banned?("1.2.3.4")) end end
23.791667
93
0.626095
e2e1af22fd9e273faa5ef676b2b47d5c3d46f1fc
1,828
class Admin::CategoriesController < Admin::ResourceController model_class Category helper :spm before_filter :add_assets def index redirect_to :controller => 'admin/products', :action => 'index' end # ======================================================================================================= # = added create, edit & destroy actions to override default redirect_to with Admin::ResourceController = # ======================================================================================================= def create @category = Category.create(params[:category]) redirect_to :controller => 'admin/products', :action => 'index' end def destroy Category.destroy(params[:id]) redirect_to :controller => 'admin/products', :action => 'index' end def update @category = Category.find(params[:id]) if @category.update_attributes(params[:category]) redirect_to :controller => 'admin/products', :action => 'index' else render(:action=>'edit') end end # ========================================================================== def move @category=Category.find(params[:id]) case params[:d] when 'up' @category.update_attribute(:sequence, @category.sequence.to_i - 1 ) when 'down' @category.update_attribute(:sequence, @category.sequence.to_i + 1 ) when 'top' @category.update_attribute(:sequence, 1 ) when 'bottom' @category.update_attribute(:sequence, Category.maximum(:sequence, :conditions => { :parent_id => @category.parent_id } ).to_i + 1) end redirect_to :controller => 'admin/products', :action => 'index' end protected def add_assets include_javascript("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js") include_stylesheet("/stylesheets/simple_product_manager.css") end end
32.070175
134
0.590263
03824b02bcf90f71871a978642d5672b89915f2f
650
require "salary/version" require "salary/employee" module Salary def self.run(args) sub_cmd = args.shift case sub_cmd when "AddEmp" puts "AddEmp: " + args.join(", ") when "DelEmp" puts "DelEmp: " + args.join(", ") when "TimeCard" puts "TimeCard: " + args.join(", ") when "SalesReceipt" puts "SalesReceipt: " + args.join(", ") when "ServiceCharge" puts "ServiceCharge: " + args.join(", ") when "ChgEmp" puts "ChgEmp: " + args.join(", ") when "Payday" puts "Payday: " + args.join(", ") else puts "ERROR: sub command (#{sub_cmd}) is not found" end end end
24.074074
57
0.567692
39bdc9914cc49c833b6b667232fb8bd37bf96f38
2,720
module XiamiRadio class Track attr_reader :info, :title, :song_id, :album_name, :artist, :radio, :client attr_accessor :recorded def initialize(track, radio:) @info = track @title, @song_id, @album_name, @artist = track.values_at(:title, :song_id, :album_name, :artist) @radio = radio @client = Client.new user: User.instance end def location(hd: true) hd ? decode_location(hd_location) : decode_location(@info[:location]) end def duration @info[:length].to_f > 1 ? @info[:length].to_f : (@info[:length].to_f * 1_000_000) end def duration=(duration) @info[:length] = duration end def grade? @info[:grade].to_i == 1 end def reason @info[:reason] ||= {content: '来自电台推送'} OpenStruct.new @info[:reason] end def downloader @downloader ||= Downloader.new self end def file_path @info[:file_path] ||= begin downloader.start sleep 0.1 while downloader.file.nil? || File.empty?(downloader.file) downloader.file.path end end def record(point = 1) @recorded ||= begin Thread.start do client.init_http uri = client.uri path: '/count/playrecord', query: URI.encode_www_form( sid: song_id, type:10, start_point: point, _xiamitoken: client.user.xiami_token ) client.get(uri, headers: radio.headers_referer, format: :xhtml) XiamiRadio.logger.info "#{title} record completed" true end end end def fav uri = client.uri path: '/song/fav', query: URI.encode_www_form( ids: song_id, _xiamitoken: client.user.xiami_token ) res = client.get(uri, headers: radio.headers_referer, format: :js) return '操作失败 (╯‵□′)╯︵┻━┻' unless res.code == '200' grade = /player_collected\('(\d)','(\d+)'\)/.match(res.body)[1] grade == '1' ? '已添加到音乐库' : '已从音乐库中移除' end private def decode_location(location) key, tmp_url = location[0].to_i, location[1..location.length] fr, ll, lu, true_url = tmp_url.length.divmod(key), [], [], '' key.times do |i| ll << (fr[1] > 0 ? fr[0] + 1 : fr[0]) lu << tmp_url[0,ll[i]] tmp_url = tmp_url[ll[i]..tmp_url.length] fr[1] -= 1 end ll[0].times do |i| lu.each do |piece| piece[i] && true_url << piece[i] end end URI.decode(true_url).gsub('^', '0') end def hd_location @info[:hd_location] ||= begin uri = client.uri path: "/song/gethqsong/sid/#{song_id}" client.get(uri, headers: radio.headers_referer)[:location] end end end end
26.930693
102
0.580147
ff380dd283805202be9977b1ac84641aeda31cdf
3,244
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 6.1 upgrade. # # Once upgraded flip defaults one by one to migrate to the new default. # # Read the Guide for Upgrading Ruby on Rails for more info on each option. # Support for inversing belongs_to -> has_many Active Record associations. # Rails.application.config.active_record.has_many_inversing = true # Track Active Storage variants in the database. # Rails.application.config.active_storage.track_variants = true # Apply random variation to the delay when retrying failed jobs. # Rails.application.config.active_job.retry_jitter = 0.15 # Stop executing `after_enqueue`/`after_perform` callbacks if # `before_enqueue`/`before_perform` respectively halts with `throw :abort`. # Rails.application.config.active_job.skip_after_callbacks_if_terminated = true # Specify cookies SameSite protection level: either :none, :lax, or :strict. # # This change is not backwards compatible with earlier Rails versions. # It's best enabled when your entire app is migrated and stable on 6.1. # Rails.application.config.action_dispatch.cookies_same_site_protection = :lax # Generate CSRF tokens that are encoded in URL-safe Base64. # # This change is not backwards compatible with earlier Rails versions. # It's best enabled when your entire app is migrated and stable on 6.1. # Rails.application.config.action_controller.urlsafe_csrf_tokens = true # Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an # UTC offset or a UTC time. # ActiveSupport.utc_to_local_returns_utc_offset_times = true # Change the default HTTP status code to `308` when redirecting non-GET/HEAD # requests to HTTPS in `ActionDispatch::SSL` middleware. # Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 # Use new connection handling API. For most applications this won't have any # effect. For applications using multiple databases, this new API provides # support for granular connection swapping. # Rails.application.config.active_record.legacy_connection_handling = false # Make `form_with` generate non-remote forms by default. Rails.application.config.action_view.form_with_generates_remote_forms = false # Set the default queue name for the analysis job to the queue adapter default. # Rails.application.config.active_storage.queues.analysis = nil # Set the default queue name for the purge job to the queue adapter default. # Rails.application.config.active_storage.queues.purge = nil # Set the default queue name for the incineration job to the queue adapter default. # Rails.application.config.action_mailbox.queues.incineration = nil # Set the default queue name for the routing job to the queue adapter default. # Rails.application.config.action_mailbox.queues.routing = nil # Set the default queue name for the mail deliver job to the queue adapter default. # Rails.application.config.action_mailer.deliver_later_queue_name = nil # Generate a `Link` header that gives a hint to modern browsers about # preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. # Rails.application.config.action_view.preload_links_header = true
46.342857
83
0.803946
01525e3fb1a9164123b6d899b23c06d3f3f0a3c9
46
module FluVaccination VERSION = "0.1.0" end
11.5
21
0.717391
e27afd9c132d77b5bab4362225a41cb68d1b00c8
85
class DefaultProjectFolder < ApplicationRecord has_many :other_project_files end
21.25
46
0.847059