Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Update to Android SDK r22.2.1 | default['android-sdk']['name'] = 'android-sdk'
default['android-sdk']['owner'] = 'root'
default['android-sdk']['group'] = 'root'
default['android-sdk']['setup_root'] = nil # ark defaults (/usr/local) is used if this attribute is not defined
# # Last version without License Agreement b... | default['android-sdk']['name'] = 'android-sdk'
default['android-sdk']['owner'] = 'root'
default['android-sdk']['group'] = 'root'
default['android-sdk']['setup_root'] = nil # ark defaults (/usr/local) is used if this attribute is not defined
default['android-sdk']['version'] = '2... |
Apply fix on put request spec | RSpec.describe Sisecommerce::Produto do
describe '#get' do
context 'having 10 produtos available' do
it 'lists produtos available' do
produtos = Sisecommerce::Produto.get
expect(produtos.size).to eq 10
end
it 'returns produto with specific id' do
produtos = Sisecommerce:... | RSpec.describe Sisecommerce::Produto do
describe '#get' do
context 'having 10 produtos available' do
it 'lists produtos available' do
produtos = Sisecommerce::Produto.get
expect(produtos.size).to eq 10
end
it 'returns produto with specific id' do
produtos = Sisecommerce:... |
Update brad table to add column for logo path | class CreateBrands < ActiveRecord::Migration
def change
create_table :brands do |t|
t.string :brand_name, null: false
t.text :brand_description
t.text :sponsorship_rules
t.timestamps
end
end
end
| class CreateBrands < ActiveRecord::Migration
def change
create_table :brands do |t|
t.string :brand_name, null: false
t.string :logo
t.text :brand_description
t.text :sponsorship_rules
t.timestamps
end
end
end
|
Modify comment to use YARD | module Fireap::ViewModel
##
# A view object which has info of a particular Application and a Node.
class ApplicationNode
attr :appname, :version, :semaphore, :updated_at, :remote_node
# Arguments:
# - app: Fireap::Model::Application
# - node: Fireap::Model::Node
def initialize(app, node)
... | module Fireap::ViewModel
##
# A view object which has info of a particular Application and a Node.
class ApplicationNode
attr :appname, :version, :semaphore, :updated_at, :remote_node
# @param app [Fireap::Model::Application]
# @param node [Fireap::Model::Node]
def initialize(app, node)
@... |
Update method signature for delayed cancel | # Testing changes to chargify_api_ares gem for
# https://github.com/chargify/chargify_api_ares/issues/100
# Use my locally built preview of the next version
gem 'chargify_api_ares', '=1.3.2.pre'
require 'chargify_api_ares'
Chargify.configure do |c|
c.subdomain = ENV['CHARGIFY_SUBDOMAIN']
c.api_key = ENV['CHARG... | # Testing changes to chargify_api_ares gem for
# https://github.com/chargify/chargify_api_ares/issues/100
# Use my locally built preview of the next version
gem 'chargify_api_ares', '=1.3.2.pre'
require 'chargify_api_ares'
Chargify.configure do |c|
c.subdomain = ENV['CHARGIFY_SUBDOMAIN']
c.api_key = ENV['CHARG... |
Remove sleep from refine_results method to make page load faster | class EventsController < ApplicationController
def index
end
def search
@city = params[:city]
@art_events = art_event_results
@art_events_with_venues = remove_empty_venues(@art_events)
@results = refine_results(@art_events_with_venues, @city)
end
private
def art_event_results
params ... | class EventsController < ApplicationController
def index
end
def search
@city = params[:city]
@art_events = art_event_results
@art_events_with_venues = remove_empty_venues(@art_events)
@results = refine_results(@art_events_with_venues, @city)
end
private
def art_event_results
params ... |
Make attr_readers protected in Difference | module Repeatable
module Expression
class Difference < Base
def initialize(included:, excluded:)
@included = included
@excluded = excluded
end
attr_reader :included, :excluded
def include?(date)
return false if excluded.include?(date)
included.include?(dat... | module Repeatable
module Expression
class Difference < Base
def initialize(included:, excluded:)
@included = included
@excluded = excluded
end
def include?(date)
return false if excluded.include?(date)
included.include?(date)
end
def to_h
Has... |
Correct link to the repo | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/git_awesome_diff/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Max Prokopiev", "Timur Vafin", "FlatStack, LLC"]
gem.email = ["max-prokopiev@yandex.ru", "me@timurv.ru"]
gem.description = %q{Object Oriented Diffing for... | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/git_awesome_diff/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Max Prokopiev", "Timur Vafin", "FlatStack, LLC"]
gem.email = ["max-prokopiev@yandex.ru", "me@timurv.ru"]
gem.description = %q{Object Oriented Diffing for... |
Remove file date from validation | class IepDocument < ActiveRecord::Base
belongs_to :student
validates :file_name, uniqueness: { scope: :file_date, message: "one unique file name per date" }
end
| class IepDocument < ActiveRecord::Base
belongs_to :student
validates :file_name, presence: true, uniqueness: true
end
|
Fix bytesize check, closes GH-36 | require 'dalli/client'
require 'dalli/ring'
require 'dalli/server'
require 'dalli/version'
require 'dalli/options'
unless String.respond_to?(:bytesize)
class String
alias_method :bytesize, :size
end
end
module Dalli
# generic error
class DalliError < RuntimeError; end
# socket/server communication error... | require 'dalli/client'
require 'dalli/ring'
require 'dalli/server'
require 'dalli/version'
require 'dalli/options'
unless ''.respond_to?(:bytesize)
class String
alias_method :bytesize, :size
end
end
module Dalli
# generic error
class DalliError < RuntimeError; end
# socket/server communication error
c... |
Fix for redirects on production (consider_all_requests_local = false) | module SpreeRedirects
class RedirectMiddleware
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
path = [ env["PATH_INFO"], env["QUERY_STRING"] ].join("?").sub(/[\/\?\s]*$/, "").strip
if status == 404 && url = find_redirect(path)
... | module SpreeRedirects
class RedirectMiddleware
def initialize(app)
@app = app
end
def call(env)
begin
# when consider_all_requests_local is false, an exception is raised for 404
status, headers, body = @app.call(env)
rescue ActionController::RoutingError => e
... |
Add :merger attr for testing | # Factorial Delegator for Item Merger Class
class Poloxy::ItemMerge
def initialize config: nil
@config = config || Poloxy::Config.new
merger = config.deliver['item']['merger']
merger_s = merger.extend(CamelSnake).to_snake
require_relative "item_merge/#{merger_s}"
klass = Object.const_get("Polox... | # Factorial Delegator for Item Merger Class
class Poloxy::ItemMerge
attr :merger
def initialize config: nil
@config = config || Poloxy::Config.new
merger = config.deliver['item']['merger']
merger_s = merger.extend(CamelSnake).to_snake
require_relative "item_merge/#{merger_s}"
klass = Object.... |
Update IdeaController spec pending test messages | require 'spec_helper'
describe IdeasController do
before do
@idea = create(:idea)
end
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
describe "GET 'new'" do
it "returns http success" do
get 'new'
response.should ... | require 'spec_helper'
describe IdeasController do
before do
@idea = create(:idea)
end
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
describe "GET 'new'" do
it "returns http success" do
get 'new'
response.should ... |
Remove defaults from user creds | Sequel.migration do
up do
create_table :'pw-users' do
column :id, :uuid, default: Sequel.function(:uuid_generate_v4), primary_key: true
String :email
String :username
String :name
String :role
TrueClass :active, default: true
String ... | Sequel.migration do
up do
create_table :'pw-users' do
column :id, :uuid, default: Sequel.function(:uuid_generate_v4), primary_key: true
String :email
String :username
String :name
String :role
TrueClass :active, default: true
String ... |
Use :swallow_stderr instead of not thread safe silence_stream(STDERR) | module Paperclip
class GeometryDetector
def initialize(file)
@file = file
raise_if_blank_file
end
def make
geometry = GeometryParser.new(geometry_string.strip).make
geometry || raise(Errors::NotIdentifiedByImageMagickError.new)
end
private
def geometry_string
b... | module Paperclip
class GeometryDetector
def initialize(file)
@file = file
raise_if_blank_file
end
def make
geometry = GeometryParser.new(geometry_string.strip).make
geometry || raise(Errors::NotIdentifiedByImageMagickError.new)
end
private
def geometry_string
b... |
Remove unused exact position method call | # We have to import the minecraft api module to do anything in the minecraft world
require_relative 'mcpi/minecraft'
=begin
First thing you do is create a connection to minecraft
This is like dialling a phone.
It sets up a communication line between your script and the minecraft world
=end
# Create a connection to Mi... | # We have to import the minecraft api module to do anything in the minecraft world
require_relative 'mcpi/minecraft'
=begin
First thing you do is create a connection to minecraft
This is like dialling a phone.
It sets up a communication line between your script and the minecraft world
=end
# Create a connection to Mi... |
Update yajl gemspec to >= 1.0 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "bldr/version"
Gem::Specification.new do |s|
s.name = "bldr"
s.version = Bldr::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Alex Sharp"]
s.email = ["ajsharp@gmail.com"]
s.homepage = "https://... | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "bldr/version"
Gem::Specification.new do |s|
s.name = "bldr"
s.version = Bldr::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Alex Sharp"]
s.email = ["ajsharp@gmail.com"]
s.homepage = "https://... |
Add method to print crosstabs | require 'csv'
class AnalyzeAssessmentsTable < Struct.new(:path)
def contents
encoding_options = {
invalid: :replace,
undef: :replace,
replace: ''
}
@file ||= File.read(path).encode('UTF-8', 'binary', encoding_options)
.gsub(/\\\\/, '')
... | require 'csv'
class AnalyzeAssessmentsTable < Struct.new(:path)
def contents
encoding_options = {
invalid: :replace,
undef: :replace,
replace: ''
}
@file ||= File.read(path).encode('UTF-8', 'binary', encoding_options)
.gsub(/\\\\/, '')
... |
FIX an incorrect regular expression. | module Embulk
module Input
class Presto < InputPlugin
class ExplainParser
def self.parse(explain_result)
explain_text = explain_result.flatten.last.lines.first
column_name_raw, column_type_raw = explain_text.split(' => ')
names = column_name_raw.split('[').last.split(']... | module Embulk
module Input
class Presto < InputPlugin
class ExplainParser
def self.parse(explain_result)
explain_text = explain_result.flatten.last.lines.first
column_name_raw, column_type_raw = explain_text.split(' => ')
names = column_name_raw.split('[').last.split(']... |
Use a get request rather than post request in spec. | require 'spec_helper'
RSpec.describe SeeYourRequests do
context 'HTTP methods' do
before do
$stdout = StringIO.new
end
it 'returns 200 status for get request' do
get '/'
expect(last_response).to be_ok
end
it 'returns 200 status for post request' do
post '/', {}
ex... | require 'spec_helper'
RSpec.describe SeeYourRequests do
context 'HTTP methods' do
before do
$stdout = StringIO.new
end
it 'returns 200 status for get request' do
get '/'
expect(last_response).to be_ok
end
it 'returns 200 status for post request' do
post '/', {}
ex... |
Add JSON as an inflection | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... |
Add test code for `ransacker :full_name` | describe Comable::Address do
it { is_expected.to belong_to(:user).class_name(Comable::User.name).autosave(false) }
it { is_expected.to validate_presence_of(:family_name) }
it { is_expected.to validate_presence_of(:first_name) }
it { is_expected.to validate_presence_of(:zip_code) }
it { is_expected.to validat... | describe Comable::Address do
it { is_expected.to belong_to(:user).class_name(Comable::User.name).autosave(false) }
it { is_expected.to validate_presence_of(:family_name) }
it { is_expected.to validate_presence_of(:first_name) }
it { is_expected.to validate_presence_of(:zip_code) }
it { is_expected.to validat... |
Change to new icons again | module ApplicationHelper
def new_session_path(scope)
new_user_session_path
end
def row_class(pr)
case pr.state
when 'passed', 'agreed', 'accepted'
'success'
when 'waiting'
'warning'
when 'blocked', 'dead', 'rejected'
'danger'
end
end
def user_row_class(st... | module ApplicationHelper
def new_session_path(scope)
new_user_session_path
end
def row_class(pr)
case pr.state
when 'passed', 'agreed', 'accepted'
'success'
when 'waiting'
'warning'
when 'blocked', 'dead', 'rejected'
'danger'
end
end
def user_row_class(st... |
Add EOL to ability spec. | require 'spec_helper'
describe Ability do
context "as singleton" do
roles = Ability.roles
roles_collection = Ability.roles_for_collection
roles.should == ['admin', 'accountant']
roles_collection.should == [['Administrator', 'admin'], ['Buchhalter', 'accountant']]
end
end | require 'spec_helper'
describe Ability do
context "as singleton" do
roles = Ability.roles
roles_collection = Ability.roles_for_collection
roles.should == ['admin', 'accountant']
roles_collection.should == [['Administrator', 'admin'], ['Buchhalter', 'accountant']]
end
end
|
Sort legend on diversity pies alphabetically | class DiversityDashboard < MetricsHelper
def self.gender_total
data = []
(load_metric 'diversity-gender')['value']['total'].each_pair do |gender, value|
data << {label: gender, value: value}
end
data
end
def self.gender_board
team("board")
end
def self.gender_leadership
te... | class DiversityDashboard < MetricsHelper
def self.gender_total
data = []
(load_metric 'diversity-gender')['value']['total'].each_pair do |gender, value|
data << {label: gender, value: value}
end
data.sort_by { |d| d[:label] }
end
def self.gender_board
team("board")
end
def sel... |
Allow client-specified handling of results. | require 'spinoza/system/node'
require 'spinoza/calvin/sequencer'
require 'spinoza/calvin/scheduler'
class Calvin::Node < Spinoza::Node
attr_reader :sequencer, :scheduler
attr_reader :log, :meta_log
def initialize *tables, log: nil, meta_log: nil,
sequencer: nil, scheduler: nil, **rest
super *tables,... | require 'spinoza/system/node'
require 'spinoza/calvin/sequencer'
require 'spinoza/calvin/scheduler'
class Calvin::Node < Spinoza::Node
attr_reader :sequencer, :scheduler
attr_reader :log, :meta_log
def initialize *tables, log: nil, meta_log: nil,
sequencer: nil, scheduler: nil, **rest
super *tables,... |
Add a class to represent negated objects for events | require 'discordrb/events/utility'
module Discordrb::Events
class EventHandler
include Discordrb::Events::Utility
def initialize(attributes, block)
@attributes = attributes
@block = block
end
def matches?(event)
raise "Attempted to call matches?() from a generic EventHandler"
e... | require 'discordrb/events/utility'
def not(object)
Negated.new(object)
end
module Discordrb::Events
class Negated
attr_reader :object
def initialize(object); @object = object; end
end
class EventHandler
include Discordrb::Events::Utility
def initialize(attributes, block)
@attributes = a... |
Add attributes to the Customer class | module WavesUtilities
class Customer
attr_accessor(
:id,
:name,
:address_1,
:address_2,
:address_3,
:town,
:county,
:postcode,
:country,
:nationality,
:email,
:phone_number,
:declared_at,
:registered_customer_id,
:imo_number... | module WavesUtilities
class Customer
attr_accessor(
:id,
:name,
:address_1,
:address_2,
:address_3,
:town,
:county,
:postcode,
:country,
:nationality,
:email,
:phone_number,
:declared_at,
:registered_customer_id,
:imo_number... |
Fix setting default hex color input | class ColorInput < SimpleForm::Inputs::Base
def input(wrapper_options)
hex_code = object.try(attribute_name).presence || options.delete(:hex_code).presence || default_hex_code
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
merged_input_options.merge!(type: :color)
c... | class ColorInput < SimpleForm::Inputs::Base
def input(wrapper_options)
hex_code = object.try(attribute_name).presence || options.delete(:hex_code).presence || default_hex_code
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
merged_input_options.merge!(type: :color, value:... |
Make all hashes 1.8 compatible | class Business < ActiveRecord::Base
belongs_to :user
belongs_to :owner, :polymorphic => true
has_many :business_categories
has_many :categories, :through => :business_categories
structure do
name "The Kernel's favourite fried chickens", :was => :title
website "http://www.googl... | class Business < ActiveRecord::Base
belongs_to :user
belongs_to :owner, :polymorphic => true
has_many :business_categories
has_many :categories, :through => :business_categories
structure do
name "The Kernel's favourite fried chickens", :was => :title
website "http://www.googl... |
Add vendor dir to gemspec files list | # encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "glow/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "glow"
s.version = Glow::VERSION
s.authors = ["Daniel Kirsch", "Klaus Fleerkötter"]
s.ema... | # encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "glow/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "glow"
s.version = Glow::VERSION
s.authors = ["Daniel Kirsch", "Klaus Fleerkötter"]
s.ema... |
Update to be Datamapper 1.0 compatible | # encoding: utf-8
module Rubyzome
# TODO: centralize configuration for example: default is app/ directory (should be different)
# Include all controllers
Dir["app/controllers/*.rb"].each { |file| require file }
# Include all specific views (if any)
Dir["app/views/*/*.rb"].each do |file|
... | # encoding: utf-8
module Rubyzome
# TODO: centralize configuration for example: default is app/ directory (should be different)
# Include all controllers
Dir["app/controllers/*.rb"].each { |file| require file }
# Include all specific views (if any)
Dir["app/views/*/*.rb"].each do |file|
... |
Test to ensure the hostname is set to the uuid of the VM | require 'spec_helper'
# Ensure hostname is not carried over from live-cd build
describe command('hostname') do
it { should_not return_stdout 'debian-7-blank' }
end
| require 'spec_helper'
# Ensure hostname is not carried over from live-cd build
describe command('hostname') do
it { should_not return_stdout 'debian-7-blank' }
end
# Hostname should retunr the UUID
uuid = `mdata-get sdc:uuid`
describe command('hostname') do
it { should return_stdout uuid }
end
|
Add EHOSTDOWN to rescuable errors | require "timeout"
require "socket"
class Godot
attr_reader :host, :port
attr_writer :interval, :timeout
def self.wait!(host, port)
new(host, port).wait!
end
def self.wait(host, port)
new(host, port).wait
end
def self.match!(host, port, pattern, path = "", options = "-ks")
new(host, port).m... | require "timeout"
require "socket"
class Godot
attr_reader :host, :port
attr_writer :interval, :timeout
def self.wait!(host, port)
new(host, port).wait!
end
def self.wait(host, port)
new(host, port).wait
end
def self.match!(host, port, pattern, path = "", options = "-ks")
new(host, port).m... |
Use the 'info' key from the `auth_hash` | require 'omniauth-oauth2'
begin
require 'dotenv'
Dotenv.load
rescue LoadError
end
module OmniAuth
module Strategies
class Radius < OmniAuth::Strategies::OAuth2
def self.provider_url
Kracken::PROVIDER_URL
end
option :client_options, {
site: provider_url,
authorize_... | require 'omniauth-oauth2'
begin
require 'dotenv'
Dotenv.load
rescue LoadError
end
module OmniAuth
module Strategies
class Radius < OmniAuth::Strategies::OAuth2
def self.provider_url
Kracken::PROVIDER_URL
end
option :client_options, {
site: provider_url,
authorize_... |
Add require statements for file | require 'grape'
require_relative './worker.rb'
require_relative '../models/build.rb'
require_relative '../entities/build.rb'
require_relative './resources/build.rb'
module Ephemeral
class API < Grape::API
version 'v1', vendor: 'factor'
format :json
group(:builds) { mount Ephemeral::Resources::Build }
... | require 'grape'
require_relative './worker.rb'
require_relative '../models/build.rb'
require_relative '../entities/build.rb'
require_relative './resources/build.rb'
require_relative '../models/file.rb'
require_relative '../entities/file.rb'
require_relative './resources/file.rb'
module Ephemeral
class API < Grape::... |
Test present forms of the copular verb | require 'helper'
class TestVerbs < Test::Unit::TestCase
def test_copular_conjugation
assert_equal :am, Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :singular)
end
def test_irregular_conjugation
assert_equal :break, Verbs::Conjugator.conjugate(:break, :tense => :p... | require 'helper'
class TestVerbs < Test::Unit::TestCase
def test_copular_conjugation
assert_equal :am, Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :first, :plurality => :singular)
assert_equal :are, Verbs::Conjugator.conjugate(:be, :tense => :present, :person => :second, :plurality => :si... |
Add check to prevent incrementing score with no line | require './core/tetrimino'
class Player
def initialize(game)
@score = 0
@linesCleared = 0
@combo = 0
@game = game
@board = Board.new
end
# Increments the score of the player relative to the number of lines he just cleared and his current combo
def increment_scor... | require './core/tetrimino'
class Player
def initialize(game)
@score = 0
@linesCleared = 0
@combo = 0
@game = game
@board = Board.new
end
# Increments the score of the player relative to the number of lines he just cleared and his current combo
def increment_scor... |
Support destroying a user's session in Rails 5.2 | module RapidRack
module DefaultReceiver
def receive(env, claims)
attrs = map_attributes(env, claims['https://aaf.edu.au/attributes'])
store_id(env, subject(env, attrs).id)
finish(env)
end
def map_attributes(_env, attrs)
attrs
end
def store_id(env, id)
env['rack.sess... | module RapidRack
module DefaultReceiver
def receive(env, claims)
attrs = map_attributes(env, claims['https://aaf.edu.au/attributes'])
store_id(env, subject(env, attrs).id)
finish(env)
end
def map_attributes(_env, attrs)
attrs
end
def store_id(env, id)
env['rack.sess... |
Add a tool to filter out openflow messages from stdout logs | #!/usr/bin/env ruby
input_file = ARGV.shift
input = File.open(input_file)
while line = input.gets
if line =~ /^c.*OF Message START/
line = input.gets
while line !~ /OF Message END/
puts line if line =~ /^c/ and line !~ /xid:/
line = input.gets
end
end
end
| |
Add unit test for GameSetup service object | require 'spec_helper'
require 'kenny_g/game_setup'
describe GameSetup do
let(:options) { { winning_score: 100, players: ['beatrix'] } }
let(:game_setup) { described_class.new(options) }
describe '#add_player' do
it 'increments the player count' do
expect{ game_setup.add_player(name: 'lilly') }
... | |
Update Custom RSpec Matcher for Refactored Order Class | RSpec::Matchers.define :contain_nil_element do |element|
match do |markup|
markup =~ /<#{element} xsi:nil="true"><\/#{element}>/
end
failure_message_for_should do |markup|
"expected markup to contain element #{element} with an xsi:nil attribute but received:\n#{markup}"
end
failure_message_for_shoul... | RSpec::Matchers.define :contain_nil_element do |element|
match do |markup|
markup =~ /<#{element} xsi:nil="true"\/>/
end
failure_message_for_should do |markup|
"expected markup to contain element #{element} with an xsi:nil attribute but received:\n#{markup}"
end
failure_message_for_should_not do |ma... |
Test for 10. 7 to 9 are not bringing anything new to change the code | require "test/unit"
require "shoulda"
class FizzBuzz
def self.fizzable?(n)
n % 3 == 0
end
def self.say(n)
return "Fizz" if fizzable? n
return "Buzz" if n == 5
n.to_s
end
end
class TestFizzbuzz < Test::Unit::TestCase
should "say 1 for 1" do
assert_equal "1", FizzBuzz.say(1)
end
sho... | require "test/unit"
require "shoulda"
class FizzBuzz
def self.fizzable?(n)
n % 3 == 0
end
def self.say(n)
return "Fizz" if fizzable? n
return "Buzz" if n == 5
n.to_s
end
end
class TestFizzbuzz < Test::Unit::TestCase
should "say 1 for 1" do
assert_equal "1", FizzBuzz.say(1)
end
sho... |
Revert "Remove append_view_path from api ControllerSetup" | require 'spree/api/responders'
module Spree
module Api
module ControllerSetup
def self.included(klass)
klass.class_eval do
include AbstractController::Rendering
include AbstractController::ViewPaths
include AbstractController::Callbacks
include AbstractContro... | require 'spree/api/responders'
module Spree
module Api
module ControllerSetup
def self.included(klass)
klass.class_eval do
include AbstractController::Rendering
include AbstractController::ViewPaths
include AbstractController::Callbacks
include AbstractContro... |
Update Razer Synapse.app to v1.45 | cask :v1 => 'razer-synapse' do
version '1.44'
sha256 '63c739c78d4f537ec64b32126fc358fba4840194296e45bd7c22638af6529984'
# amazonaws.com is the official download host per the vendor homepage
url "https://razerdrivers.s3.amazonaws.com/drivers/Synapse2/mac/Razer_Synapse_Mac_Driver_v#{version}.dmg"
name 'Razer S... | cask :v1 => 'razer-synapse' do
version '1.45'
sha256 '4b4368bf5f90cb94667a60a120d49b9073329ba6d9efcd4f5108cf709bfe8115'
# amazonaws.com is the official download host per the vendor homepage
url "https://razerdrivers.s3.amazonaws.com/drivers/Synapse2/mac/Razer_Synapse_Mac_Driver_v#{version}.dmg"
name 'Razer S... |
Fix uninitialized constant Timeout (NameError) | require 'json'
module Frontkick
# ref. http://docs.ruby-lang.org/ja/1.9.3/class/Timeout=3a=3aError.html
class TimeoutLocal < ::Timeout::Error; end
class Locked < StandardError; end
class Timeout < StandardError
attr_reader :pid, :command, :killed
def initialize(pid, command, killed)
@pid = pid
... | require 'json'
require 'timeout'
module Frontkick
# ref. http://docs.ruby-lang.org/ja/1.9.3/class/Timeout=3a=3aError.html
class TimeoutLocal < ::Timeout::Error; end
class Locked < StandardError; end
class Timeout < StandardError
attr_reader :pid, :command, :killed
def initialize(pid, command, killed)
... |
Update gnatsd version used in tests | require 'common/retryable'
require_relative './artifact'
module Bosh::Dev
class GnatsdManager
VERSION = '0.9.6-bosh.6'
DARWIN_SHA256 = '13b9ffac19e0a733f8e7e07fcd34d8738a9942d29ce5776c396adc701e29967a'
LINUX_SHA256 = '68afe5eaad377b336f9c58511be6de10d181f04ffddd8c3522c43d856a7e760b'
BUCKET_NAME = 'bo... | require 'common/retryable'
require_relative './artifact'
module Bosh::Dev
class GnatsdManager
VERSION = '0.9.6-bosh.12'
DARWIN_SHA256 = '4880812fc854e8c7691f2fa26d74cdab278e223267fa2c70204613a906ffaa1a'
LINUX_SHA256 = 'e42777ce2da188a0f7bfb07a782c40275b8144de718b40253481e03169b05066'
BUCKET_NAME = 'b... |
Upgrade GOG.com Galaxy Client to v1.0.5.11 | cask :v1 => 'gog-galaxy' do
version '1.0.2.939'
sha256 '2c46d7aafe862bc0b2aa6b4bc95490683f8ec80f96feffb7c6f7918e2203e4e7'
url "http://cdn.gog.com/open/galaxy/client/installers/galaxy_client_#{version}.pkg"
name 'GOG Galaxy Client'
homepage 'https://www.gog.com/galaxy'
license :gratis
tags :vendor => 'GOG... | cask :v1 => 'gog-galaxy' do
version '1.0.5.11'
sha256 '1adba93ef842bff2ecf40de423abb610e215d4e40536a622e16e8d008881057b'
url "http://cdn.gog.com/open/galaxy/client/galaxy_client_#{version}.pkg"
name 'GOG Galaxy Client'
homepage 'https://www.gog.com/galaxy'
license :gratis
tags :vendor => 'GOG'
pkg "ga... |
Allow C-optimizations for even more C parser speed | #!/usr/bin/env ruby
require "mkmf"
$CFLAGS << " -ggdb -O0 -Wextra -DDEBUG_H" # only for development
should_build = true
should_build &&= have_header "ruby.h"
should_build &&= defined?(RUBY_ENGINE) && %w[ruby rbx].include?(RUBY_ENGINE)
if should_build
create_makefile("stompede/stomp/c_parser")
else
dummy_makefil... | #!/usr/bin/env ruby
require "mkmf"
$CFLAGS << " -O3"
should_build = true
should_build &&= have_header "ruby.h"
should_build &&= defined?(RUBY_ENGINE) && %w[ruby rbx].include?(RUBY_ENGINE)
if should_build
create_makefile("stompede/stomp/c_parser")
else
dummy_makefile(".")
end
|
Return correct error status for invalid access | module Drive
class ApplicationController < ::ApplicationController
# ActionController::Base
private
def ensure_admin
render_json_error(current_user) unless current_user && current_user.admin?
# raise Discourse::InvalidAccess.new unless current_user.admin?
end
def create_category... | module Drive
class ApplicationController < ::ApplicationController
# ActionController::Base
private
def ensure_admin
render json: MultiJson.dump(create_errors_json("Invalid Access")), status: 401
# render_json_error(current_user) unless current_user && current_user.admin?
# raise ... |
Add default value for dict[entry] | module Api
module V1
class DictsController < ApplicationController
def show
require "rugby-dict"
input = params[:entry]
dict = RugbyDict::Dict.from_yaml
names = RugbyDict::Dict.segment(input)
query_result = []
names.each do |word|
t = dict.query_dic... | module Api
module V1
class DictsController < ApplicationController
def show
require "rugby-dict"
input = params[:entry] || ""
dict = RugbyDict::Dict.from_yaml
names = RugbyDict::Dict.segment(input)
query_result = []
names.each do |word|
t = dict.que... |
Fix order on rss feed | class WelcomeController < ApplicationController
respond_to :html, :xml, :builder
# GET /
# GET /feed.atom
def index
@postings = Posting.readable( current_user ? current_user.roles_mask : 1).latest(CONSTANTS['num_postings_on_welcome_page'])
respond_to do |format|
format.atom {
@com... | class WelcomeController < ApplicationController
respond_to :html, :xml, :builder
# GET /
# GET /feed.atom
def index
@postings = Posting.readable( current_user ? current_user.roles_mask : 1).latest(CONSTANTS['num_postings_on_welcome_page']).order('updated_at asc')
respond_to do |format|
form... |
Update spec to support authorization. | require 'spec_helper'
describe 'global_features' do
include PavlovSupport
let(:current_user) { create :user }
it 'initial state is empty' do
as(current_user) do |pavlov|
features = pavlov.interactor :'global_features/all'
expect(features).to eq []
end
end
it 'retains set features' do
... | require 'spec_helper'
describe 'global_features' do
include PavlovSupport
let(:current_user) do
OpenStruct.new(
agrees_tos: true,
admin?: true,
features: [],
)
end
it 'initial state is empty' do
as(current_user) do |pavlov|
features = pavlov.interactor :'global_features/al... |
Move asset location update job to core where it belongs | #------------------------------------------------------------------------------
#
# AssetLocationUpdateJob
#
# Updates an assets location
#
#------------------------------------------------------------------------------
class AssetLocationUpdateJob < AbstractAssetUpdateJob
def execute_job(asset)
asset.upd... | |
Update variants with count on-hand, to keep direct queries happy | module Spree
Variant.class_eval do
include ActiveModel::Validations
validates :sku, 'spree_fishbowl/sku_in_fishbowl' => true, :if => "sku.present?"
alias_method :orig_on_hand, :on_hand
alias_method :orig_on_hand=, :on_hand=
def on_hand
return orig_on_hand if (!SpreeFishbowl.enabled? || !s... | module Spree
Variant.class_eval do
include ActiveModel::Validations
validates :sku, 'spree_fishbowl/sku_in_fishbowl' => true, :if => "sku.present?"
alias_method :orig_on_hand, :on_hand
alias_method :orig_on_hand=, :on_hand=
def on_hand
return orig_on_hand if (!SpreeFishbowl.enabled? || !s... |
Fix failing test for PiwikPlugins hook | require File.expand_path('../helper', __FILE__)
class PiwikPluginsTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push
svc = service :push, {}, 'a' => 1
@stubs.post "/postreceive-hook" do |env|
assert_equal 'plugins.piwik.org', env[:url].host
d... | require File.expand_path('../helper', __FILE__)
class PiwikPluginsTest < Service::TestCase
include Service::HttpTestMethods
def test_push
svc = service({}, 'a' => 1)
@stubs.post "/postreceive-hook" do |env|
body = JSON.parse(env[:body])
assert_equal 'plugins.piwik.org', env[:url].host
a... |
Call properly `t` method in error_and_exit | module Vagrant
module Util
def self.included(base)
base.extend Vagrant::Util
end
def wrap_output
puts "====================================================================="
yield
puts "====================================================================="
end
def error_a... | module Vagrant
module Util
def self.included(base)
base.extend Vagrant::Util
end
def wrap_output
puts "====================================================================="
yield
puts "====================================================================="
end
def error_a... |
Put CookieMonster before ActionDispatch::Cookies - that way Rack::Cache won't come between them and mess things up | require 'dragonfly'
require 'rails'
module Dragonfly
class Railtie < ::Rails::Railtie
initializer "dragonfly.railtie.initializer" do |app|
app.middleware.insert 1, Dragonfly::CookieMonster
end
end
end
| require 'dragonfly'
require 'rails'
module Dragonfly
class Railtie < ::Rails::Railtie
initializer "dragonfly.railtie.initializer" do |app|
app.middleware.insert_before 'ActionDispatch::Cookies', Dragonfly::CookieMonster
end
end
end
|
Add rake task that generates fake logs | namespace :fake_logs do
desc "Generates fake logs entries"
task generate: :environment do
count = ENV["COUNT"].to_i
set_uuid = SecureRandom.uuid
count.times do |i|
Log.create!(username: "fake user", application: "fake app", activity: "fake activity", event: "fake event",
time: Tim... | |
Remove the "." in the summary to conform to the rest of the CP commands | module Pod
class Command
class Keys < Command
include ProjectDirectory
require 'pod/command/keys/list'
require 'pod/command/keys/set'
require 'pod/command/keys/get'
require 'pod/command/keys/rm'
require 'pod/command/keys/export'
self.summary = 'A key value store for env... | module Pod
class Command
class Keys < Command
include ProjectDirectory
require 'pod/command/keys/list'
require 'pod/command/keys/set'
require 'pod/command/keys/get'
require 'pod/command/keys/rm'
require 'pod/command/keys/export'
self.summary = 'A key value store for env... |
Remove unnecessary check and parentheses. | class CorporateInformationPagesController < DocumentsController
prepend_before_filter :find_organisation
def show
@corporate_information_page = @document
if @organisation.is_a? WorldwideOrganisation
render 'show_worldwide_organisation'
else
render :show
end
end
def find_document_o... | class CorporateInformationPagesController < DocumentsController
prepend_before_filter :find_organisation
def show
@corporate_information_page = @document
if @organisation.is_a? WorldwideOrganisation
render 'show_worldwide_organisation'
else
render :show
end
end
def find_document_o... |
Create unique addresses by default. | require 'spree/testing_support/factories'
require 'securerandom'
FactoryGirl.modify do
# Modify the address factory to generate unique addresses.
factory :address do
address2 { SecureRandom.uuid }
end
end
| |
Add hysteresis to the allowed params. | class ThermostatsController < ApplicationController
respond_to :html, :json
def update
@thermostat = Thermostat.find( params[:id] )
@thermostat.update_attributes( thermostat_params )
respond_with @thermostat
end
private
def thermostat_params
params.require( :thermostat ).permit( :name, :c... | class ThermostatsController < ApplicationController
respond_to :html, :json
def update
@thermostat = Thermostat.find( params[:id] )
@thermostat.update_attributes( thermostat_params )
respond_with @thermostat
end
private
def thermostat_params
params.require( :thermostat ).permit( :name, :c... |
Remove indent of product description on iPhone | require "open_food_network/scope_variant_to_hub"
class Api::ProductSerializer < ActiveModel::Serializer
include ActionView::Helpers::SanitizeHelper
attributes :id, :name, :permalink, :meta_keywords
attributes :group_buy, :notes, :description, :description_html
attributes :properties_with_values, :price
has... | require "open_food_network/scope_variant_to_hub"
class Api::ProductSerializer < ActiveModel::Serializer
include ActionView::Helpers::SanitizeHelper
attributes :id, :name, :permalink, :meta_keywords
attributes :group_buy, :notes, :description, :description_html
attributes :properties_with_values, :price
has... |
Use more typical pavlov for integration tests. | require 'spec_helper'
describe Interactors::Users::Delete do
include PavlovSupport
it 'persistant stores the delete flag' do
user = create :full_user
initial_username = user.username
expect(user.deleted).to eq(false)
as(user) do |pavlov|
described_class.new(user_id: user.id.to_s, pavlov_opti... | require 'spec_helper'
describe Interactors::Users::Delete do
include PavlovSupport
it 'persistant stores the delete flag' do
user = create :full_user
initial_username = user.username
expect(user.deleted).to eq(false)
as(user) do |pavlov|
pavlov.interactor :'users/delete', user_id: user.id.to... |
Move Common.cmd(:systemctl) calls to a private method | module LinuxAdmin
class SystemdService < Service
def running?
Common.run(Common.cmd(:systemctl),
:params => {nil => ["status", name]}).exit_status == 0
end
def enable
Common.run!(Common.cmd(:systemctl),
:params => {nil => ["enable", name]})
self
en... | module LinuxAdmin
class SystemdService < Service
def running?
Common.run(command_path,
:params => {nil => ["status", name]}).exit_status == 0
end
def enable
Common.run!(command_path,
:params => {nil => ["enable", name]})
self
end
def disable
... |
Use association as a uniqueness scope not the actual column name | class Notebook < ActiveRecord::Base
belongs_to :user
validates :name, presence: true
validates :name, uniqueness: { scope: :user_id }
end
| class Notebook < ActiveRecord::Base
belongs_to :user
validates :name, presence: true
validates :name, uniqueness: { scope: :user }
end
|
Update user model test to reflect additional email validation. | require 'rails_helper'
describe User do
context "migration validations" do
it "is valid with an email and password hash" do
user = User.new(
email: "me@me.com",
password_hash: "god")
expect(user).to be_valid
end
it "is invalid without an email" do
expect(User.new(email:... | require 'rails_helper'
describe User do
context "migration validations" do
it "is valid with an email and password hash" do
user = User.new(
email: "me@me.com",
password_hash: "god")
expect(user).to be_valid
end
it "is invalid without an email" do
expect(User.new(email:... |
Add latest player counts JSON route | require 'sinatra/redis'
module Sinatra
module TreeStats
module Routing
module PlayerCounts
def self.registered(app)
app.get '/player_counts/?' do
haml :player_counts
end
app.get '/player_counts.json' do
content_type :json
# Query f... | require 'sinatra/redis'
module Sinatra
module TreeStats
module Routing
module PlayerCounts
def self.registered(app)
app.get '/player_counts/?' do
haml :player_counts
end
app.get '/player_counts.json' do
content_type :json
# Query f... |
Rename find_user to find_model for the users controller. | class Backend::UsersController < Backend::BaseController
include Concerns::PaginationController
before_action :find_user, only: [:show, :edit, :update, :destroy]
before_action -> { breadcrumb.add t('b.users'), backend_users_path }
def index
@search = User.ransack params[:q]
@users = @search.result(dis... | class Backend::UsersController < Backend::BaseController
include Concerns::PaginationController
before_action :find_model, only: [:show, :edit, :update, :destroy]
before_action -> { breadcrumb.add t('b.users'), backend_users_path }
def index
@search = User.ransack params[:q]
@users = @search.result(di... |
Add pseudocode of separate_comma method. | # Numbers to Commas Solo Challenge
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input?
# What is the output? (i.e. What should ... | # Numbers to Commas Solo Challenge
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
=begin
# What is the input?
# Input: positive integer
# What... |
Revert "Update tests to work for ruby 1.9" | RSpec.describe(Jekyll::Compose::FileInfo) do
let(:open_and_closing_tag) { "---\n" }
let(:layout_content) { "post\n" }
describe '#content' do
context 'with a title of only words' do
let(:expected_title) { "A test arg parser\n" }
subject { described_class.new Jekyll::Compose::ArgParser.new(
... | RSpec.describe(Jekyll::Compose::FileInfo) do
describe '#content' do
context 'with a title of only words' do
let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '')
---
layout: post
title: A test arg parser
---
CONTENT
}
let(:parsed_args) { Jekyll::Comp... |
Remove date.today specifier in gemspec | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'delayed_job_mongo_mapper'
s.summary = "MongoMapper backend for delayed_job"
s.version = '1.0.0'
s.authors = 'Andrew Timberlake'
s.date = Date.today.to_s
s.email = 'andrew@an... | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'delayed_job_mongo_mapper'
s.summary = "MongoMapper backend for delayed_job"
s.version = '1.0.0'
s.authors = 'Andrew Timberlake'
s.email = 'andrew@andrewtimberlake.com'
s.extra_rdoc_files... |
Add support for immutable objects to session | # encoding: utf-8
module SpecHelper
def mock_model(*attributes)
Class.new {
include Equalizer.new(*attributes)
attributes.each { |attribute| attr_accessor attribute }
def initialize(attrs = {}, &block)
attrs.each { |name, value| send("#{name}=", value) }
instance_eval(&block)... | # encoding: utf-8
module SpecHelper
def mock_model(*attributes, &block)
model = Class.new {
include Equalizer.new(*attributes)
const_set(:ATTRIBUTES, attributes)
attributes.each { |name| attr_accessor name }
def initialize(attrs = {}, &block)
attrs.each { |name, value| send("#... |
Refactor DbFileBackend for Rails 4 AREL conformity | module Technoweenie # :nodoc:
module AttachmentFu # :nodoc:
module Backends
# Methods for DB backed attachments
module DbFileBackend
def self.included(base) #:nodoc:
Object.const_set(:DbFile, Class.new(ActiveRecord::Base)) unless Object.const_defined?(:DbFile)
base.belongs_... | module Technoweenie # :nodoc:
module AttachmentFu # :nodoc:
module Backends
# Methods for DB backed attachments
module DbFileBackend
def self.included(base) #:nodoc:
Object.const_set(:DbFile, Class.new(ActiveRecord::Base)) unless Object.const_defined?(:DbFile)
base.belongs_... |
Make signing conditional for building the gem, so that external systems such as Travis may build it without needing to have a private key present | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'manticore/version'
Gem::Specification.new do |spec|
spec.name = "manticore"
spec.version = Manticore::VERSION
spec.authors = ["Chris Heald"]
spec.email = ["ch... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'manticore/version'
Gem::Specification.new do |spec|
spec.name = "manticore"
spec.version = Manticore::VERSION
spec.authors = ["Chris Heald"]
spec.email = ["ch... |
Use let! instead of let+before hack. | require 'spec_helper'
describe Task do
context "for three sample tasks in a list" do
let(:list) { create(:task_list) }
let(:task1) { create(:task, list: list) }
let(:task2) { create(:task, list: list) }
let(:task3) { create(:task, list: list) }
before do
# Force creation in proper order.
... | require 'spec_helper'
describe Task do
context "for three sample tasks in a list" do
let(:list) { create(:task_list) }
let!(:task3) { create(:task, list: list) }
let!(:task2) { create(:task, list: list) }
let!(:task1) { create(:task, list: list) }
it "should reorder other tasks in the list when ... |
Update column names for new helpspot version. | require 'sequel'
module Opscode
module HelpspotSSO
DATABASE_URI = nil
def helpspot_db
@helpspot_db ||= Sequel.connect(DATABASE_URI)
end
def create_helpspot_user(email)
return 0 unless DATABASE_URI
portal_users = helpspot_db[:HS_Portal_Login]
portal_users.on_duplicate_key_upd... | require 'sequel'
module Opscode
module HelpspotSSO
DATABASE_URI = nil
def helpspot_db
@helpspot_db ||= Sequel.connect(DATABASE_URI)
end
def create_helpspot_user(email)
return 0 unless DATABASE_URI
portal_users = helpspot_db[:HS_Portal_Login]
portal_users.on_duplicate_key_upd... |
Add logic to find next pair of votes | class VotesController < ApplicationController
def new
if flash[:prev_winner_id]
@prev_winner = Artist.find(flash[:prev_winner_id])
@prev_loser = Artist.find(flash[:prev_loser_id])
scores = Artist.score
rankings = Artist.ranking
@prev_winner_score = scores[@prev_winner.id]
@pre... | class VotesController < ApplicationController
def new
if flash[:prev_winner_id]
@prev_winner = Artist.find(flash[:prev_winner_id])
@prev_loser = Artist.find(flash[:prev_loser_id])
scores = Artist.score
rankings = Artist.ranking
@prev_winner_score = scores[@prev_winner.id]
@pre... |
Fix gemspec - must include dtrace.rb | Gem::Specification.new do |s|
s.name = 'ruby-dtrace'
s.version = Dtrace::VERSION
s.platform = Gem::Platform::RUBY
s.summary = <<-DESC.strip.gsub(/\n\s+/, " ")
ruby-dtrace is Ruby bindings for Dtrace, which lets you write D-based
programs in Ruby, and add probes to your Ruby pr... | $:<<'./lib'
require 'dtrace'
Gem::Specification.new do |s|
s.name = 'ruby-dtrace'
s.version = Dtrace::VERSION
s.platform = Gem::Platform::RUBY
s.summary = <<-DESC.strip.gsub(/\n\s+/, " ")
ruby-dtrace is Ruby bindings for Dtrace, which lets you write D-based
programs in Ruby, ... |
Use let definition for assigned variable | require 'rails_helper'
<% output_attributes = model.columns.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
RSpec.describe '<%= ns_table_name %>/new', <%= type_metatag(:view) %> do
<%= model.factory_girl_let_definitions %>
before(:each) do
assign(:<%= ns_file_name %>, <%= m... | require 'rails_helper'
<% output_attributes = model.columns.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
RSpec.describe '<%= ns_table_name %>/new', <%= type_metatag(:view) %> do
<%= model.factory_girl_let_definitions %>
<%= model.factory_girl_let_definition(action: :build) %... |
Make sure tar is installed to decompress the tarball | module DockerCookbook
class DockerInstallationTarball < DockerBase
require_relative 'helpers_installation_tarball'
include DockerHelpers::InstallationTarball
#####################
# Resource properties
#####################
resource_name :docker_installation_tarball
property :checksum, ... | module DockerCookbook
class DockerInstallationTarball < DockerBase
require_relative 'helpers_installation_tarball'
include DockerHelpers::InstallationTarball
#####################
# Resource properties
#####################
resource_name :docker_installation_tarball
property :checksum, ... |
Add missing test for Roadmap controller | require "test_helper"
class RoadmapControllerTest < ActionController::TestCase
context "GET index" do
setup do
content_store_has_random_item(base_path: "/roadmap", schema: "special_route")
end
should "set the cache expiry headers" do
get :index
assert_equal "max-age=1800, public", res... | |
Load database driver before load activerecord | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require "coveralls"
Coveralls.wear!
require "active_record"
case ENV["DB"]
when "postgres"
require "pg"
ActiveRecord::Base.establish_connection(
adapter: "postgresql",
database: "simple_taggable",
username: "postgres"
)
when "mysql"
requir... | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require "coveralls"
Coveralls.wear!
case ENV["DB"]
when "postgres"
require "pg"
require "active_record"
ActiveRecord::Base.establish_connection(
adapter: "postgresql",
database: "simple_taggable",
username: "postgres"
)
when "mysql"
requi... |
Migrate payment fee adjustments to payment objects | class MigratePaymentFeesToPayments < ActiveRecord::Migration
class Spree::Adjustment < ActiveRecord::Base
belongs_to :originator, polymorphic: true
end
def up
# Payment fee adjustments currently have the order as the `adjustable` and the payment as
# the `source`. Both `source` and `adjustable` will ... | |
Make sure git ignores nothing. | require 'shellwords'
module Kosmos
module GitAdapter
class << self
def init_repo(path)
Dir.chdir(path) do
`git init`
end
end
def commit_everything(repo_path, commit_message)
Dir.chdir(repo_path) do
`git add -A -f`
`git commit --allow-empty ... | require 'shellwords'
module Kosmos
module GitAdapter
class << self
def init_repo(path)
Dir.chdir(path) do
`git init`
File.open('.gitignore', 'w') do |file|
file.write "!*\n"
end
end
end
def commit_everything(repo_path, commit_message)
... |
Put a real source URL in the podspec | Pod::Spec.new do |s|
s.name = "RPJSContext"
s.version = "1.0.0"
s.summary = "JSContext++"
s.homepage = "http://github.com/RobotsAndPencils/RPJSContext"
s.license = 'MIT'
s.author = { "Brandon Evans" => "brandon.evans@robotsandpencils.com" }
s.source... | Pod::Spec.new do |s|
s.name = "RPJSContext"
s.version = "1.0.0"
s.summary = "JSContext++"
s.homepage = "http://github.com/RobotsAndPencils/RPJSContext"
s.license = 'MIT'
s.author = { "Brandon Evans" => "brandon.evans@robotsandpencils.com" }
s.source... |
Update rake requirement from ~> 12.0 to ~> 13.0 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'flatten_routes/version'
Gem::Specification.new do |spec|
spec.name = 'flatten_routes'
spec.version = FlattenRoutes::VERSION
spec.authors = ['Kazuhiro Serizawa']
spec.... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'flatten_routes/version'
Gem::Specification.new do |spec|
spec.name = 'flatten_routes'
spec.version = FlattenRoutes::VERSION
spec.authors = ['Kazuhiro Serizawa']
spec.... |
Make locks spec more deterministic | require 'spec_helper'
describe 'cli: locks', type: :integration do
with_reset_sandbox_before_each
context 'when a deployment is in progress' do
before do
manifest_hash = Bosh::Spec::Deployments.simple_manifest
manifest_hash['update']['canary_watch_time'] = 6000
deploy_from_scratch(manifest_h... | require 'spec_helper'
describe 'cli: locks', type: :integration do
with_reset_sandbox_before_each
context 'when a deployment is in progress' do
let(:blocking_deployment_manifest) do
manifest_hash = Bosh::Spec::Deployments.simple_manifest
manifest_hash['jobs'][0]['template'] = 'job_with_blocking_co... |
Fix JSON serialization of Reference type | module MongoModel
class Reference
attr_reader :id
def initialize(id)
@id = id
end
def to_s
id.to_s
end
def hash
id.hash
end
def blank?
id.blank?
end
def eql?(other)
case other
when Reference
id.to_s == other.i... | module MongoModel
class Reference
attr_reader :id
def initialize(id)
@id = id
end
def to_s
id.to_s
end
def hash
id.hash
end
def as_json(*)
to_s
end
def blank?
id.blank?
end
def eql?(other)
case other
... |
Handle VNF error state correctly | class ManageIQ::Providers::Openstack::CloudManager::Vnf::Status < ::OrchestrationStack::Status
def succeeded?
status.downcase == "active"
end
def failed?
status.downcase =~ /failed$/
end
def rolled_back?
status.downcase == "rollback_complete"
end
def deleted?
status.downcase == "delete_... | class ManageIQ::Providers::Openstack::CloudManager::Vnf::Status < ::OrchestrationStack::Status
def succeeded?
status.downcase == "active"
end
def failed?
status.downcase =~ /failed$/ || status.downcase == "error"
end
def rolled_back?
status.downcase == "rollback_complete"
end
def deleted?
... |
Remove rubyforge_project name from gemspec :skull: RubyForge | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "rails_erd/version"
Gem::Specification.new do |s|
s.name = "rails-erd"
s.version = RailsERD::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Rolf Timmermans"]
s.email = ["r.timmermans@voormedia.com"]... | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "rails_erd/version"
Gem::Specification.new do |s|
s.name = "rails-erd"
s.version = RailsERD::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Rolf Timmermans"]
s.email = ["r.timmermans@voormedia.com"]... |
Fix install generator auth option in common rake tasks | # frozen_string_literal: true
unless defined?(Solidus::InstallGenerator)
require 'generators/solidus/install/install_generator'
end
require 'generators/spree/dummy/dummy_generator'
namespace :common do
task :test_app, :user_class do |_t, args|
args.with_defaults(user_class: "Spree::LegacyUser")
require E... | # frozen_string_literal: true
unless defined?(Solidus::InstallGenerator)
require 'generators/solidus/install/install_generator'
end
require 'generators/spree/dummy/dummy_generator'
namespace :common do
task :test_app, :user_class do |_t, args|
args.with_defaults(user_class: "Spree::LegacyUser")
require E... |
Clean up RSpec deprecation warnings wrt 'should_not raise_error(SpecificError)' | require 'spec_helper'
require 'spree/core/product_filters'
describe 'product filters' do
# Regression test for #1709
context 'finds products filtered by brand' do
let(:product) { create(:product) }
before do
property = Spree::Property.create!(:name => "brand", :presentation => "brand")
product.... | require 'spec_helper'
require 'spree/core/product_filters'
describe 'product filters' do
# Regression test for #1709
context 'finds products filtered by brand' do
let(:product) { create(:product) }
before do
property = Spree::Property.create!(:name => "brand", :presentation => "brand")
product.... |
Call Hutch::CLI instead of spawning a process | namespace :streamy do
namespace :consumer do
desc "Start consuming"
task run: :environment do
if Rails.application.secrets.rabbitmq_uri.blank?
raise "Missing `rabbitmq_uri` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
end
system(
{
"HUTCH... | namespace :streamy do
namespace :consumer do
desc "Start consuming"
task run: :environment do
if Rails.application.secrets.rabbitmq_uri.blank?
raise "Missing `rabbitmq_uri` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
end
Hutch::Config[:uri] = Rails.applic... |
Remove unnecessary bundle exec from the command | # encoding: utf-8
namespace :metrics do
allowed_versions = %w(mri-1.9.3 rbx-1.9.3)
if allowed_versions.include?(Devtools.rvm) && system("which mutant > #{File::NULL}")
desc 'Run mutant'
task :mutant => :coverage do
project = Devtools.project
config = project.mutant
cmd = %[bundle exec m... | # encoding: utf-8
namespace :metrics do
allowed_versions = %w(mri-1.9.3 rbx-1.9.3)
if allowed_versions.include?(Devtools.rvm) && system("which mutant > #{File::NULL}")
desc 'Run mutant'
task :mutant => :coverage do
project = Devtools.project
config = project.mutant
cmd = %[mutant -r ./s... |
Add Pocket Casts for Mac v1.0 | cask :v1 => 'pocketcasts' do
version '1.0'
sha256 'fe191ceb3a7157bee5a589bed248464587526ddbaeacab122960a4144d1c87da'
url "https://github.com/mortenjust/PocketCastsOSX/releases/download/#{version}/PocketCastsOSX#{version}.zip"
appcast 'https://github.com/mortenjust/PocketCastsOSX/releases.atom'
name 'Pocket C... | |
Add a homepage and safer dependency to the gemspec. | Gem::Specification.new do |s|
s.name = "knife-wsfusion"
s.version = "0.1.0"
s.summary = "VMware Workstation/Fusion support for Knife"
s.required_rubygems_version = \
Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.author = "Christian Hammond"
s.description =... | Gem::Specification.new do |s|
s.name = "knife-wsfusion"
s.version = "0.1.0"
s.summary = "VMware Workstation/Fusion support for Knife"
s.required_rubygems_version = \
Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.author = "Christian Hammond"
s.description =... |
Update test of data to check for the method actually used rather than assume that an object that responds to :to_a can respond to :map. | module Napa
module GrapeHelpers
def represent(data, with: nil, **args)
raise ArgumentError.new(":with option is required") if with.nil?
if data.respond_to?(:to_a)
return { data: data.map{ |item| with.new(item).to_hash(args) } }
else
return { data: with.new(data).to_hash(args)}
... | module Napa
module GrapeHelpers
def represent(data, with: nil, **args)
raise ArgumentError.new(":with option is required") if with.nil?
if data.respond_to?(:map)
return { data: data.map{ |item| with.new(item).to_hash(args) } }
else
return { data: with.new(data).to_hash(args)}
... |
Use Time.zone instead of Date.today | class PrisonSchedule < Struct.new(:prison)
delegate :days_lead_time, :booking_window, to: :prison
def confirmation_email_date
staff_working_days.take(prison_processing_days).last
end
def available_visitation_dates
available_visitation_range.reduce([]) do |valid_dates, day|
valid_dates.tap do |d... | class PrisonSchedule < Struct.new(:prison)
delegate :days_lead_time, :booking_window, to: :prison
def confirmation_email_date
staff_working_days.take(prison_processing_days).last
end
def available_visitation_dates
available_visitation_range.reduce([]) do |valid_dates, day|
valid_dates.tap do |d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.