Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add code wars (7) - find duplicated number | # http://www.codewars.com/kata/558dd9a1b3f79dc88e000001/
# --- iteration 1 ---
def find_dup(arr)
arr.map{ |x| [x, arr.count(x)] }.select{ |x| x[1] == 2 }[0][0]
end
| |
Remove the code to prevent pushing to a public server | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'conoha/version'
Gem::Specification.new do |spec|
spec.name = "conoha"
spec.version = ConohaVersion::ITSELF
spec.authors = ["ka"]
spec.email = ["ka.kaosf@gmail... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'conoha/version'
Gem::Specification.new do |spec|
spec.name = "conoha"
spec.version = ConohaVersion::ITSELF
spec.authors = ["ka"]
spec.email = ["ka.kaosf@gmail... |
Disable scaling of typical_input_capacity and electricity_output_capacity | module Atlas
class Scaler::GraphScaler
# Edge attributes which must be scaled.
EDGE_ATTRIBUTES = [:demand].freeze
# Node attributes which must be scaled.
NODE_ATTRIBUTES = [
:demand,
:max_demand,
:typical_input_capacity,
:electricity_output_capacity
].freeze
# Maps to... | module Atlas
class Scaler::GraphScaler
# Edge attributes which must be scaled.
EDGE_ATTRIBUTES = [:demand].freeze
# Node attributes which must be scaled.
NODE_ATTRIBUTES = [
:demand,
:max_demand,
# Scaling of the following two attributes is disabled for the time being -
# see ... |
Remove duplicate OpenStruct monkey patch for specs | require 'backports'
require 'backports/basic_object' unless defined?(BasicObject)
require 'rubygems'
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter "/spec/"
add_group "Finalizer", "lib/data_mapper/finalizer"
add_group "Mapper", "lib/data_mapper/mapper"
add_group "Rela... | require 'backports'
require 'backports/basic_object' unless defined?(BasicObject)
require 'rubygems'
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter "/spec/"
add_group "Finalizer", "lib/data_mapper/finalizer"
add_group "Mapper", "lib/data_mapper/mapper"
add_group "Rela... |
Revert "Revert "prevent find_method test running on MRI 1.8"" | require 'helper'
MyKlass = Class.new do
def hello
"timothy"
end
def goodbye
"jenny"
end
end
describe "find-command" do
describe "find matching methods by name regex (-n option)" do
it "should find a method by regex" do
mock_pry("find-method hell MyKlass").should =~ /MyKlass.*?hello/m
e... | require 'helper'
# we turn off the test for MRI 1.8 because our source_location hack
# for C methods actually runs the methods - and since it runs ALL
# methods (in an attempt to find a match) it runs 'exit' and aborts
# the test, causing a failure. We should fix this in the future by
# blacklisting certain methods fo... |
Delete all supporting page and policy data. | class DeletePoliciesAndSupportingPages < ActiveRecord::Migration
def up
document_ids = Document.where(document_type: [
"SupportingPage",
"Policy",
]).pluck(:id)
edition_ids = Edition.where(document_id: document_ids).pluck(:id)
puts "Deleting data (but not tables) for #{edition_ids.count}... | |
Handle errors during compilation of CoffeeScript. | # -*- encoding: UTF-8 -*-
require 'rack'
require 'coffee-script'
require 'sprockets'
module Peaberry
class DotJs
def initialize
@sprockets = Sprockets::Environment.new
dot_js_dir = File.expand_path('~/.js')
@sprockets.append_path(dot_js_dir)
end
def call(env)
headers = Rack::Ut... | # -*- encoding: UTF-8 -*-
require 'rack'
require 'coffee-script'
require 'sprockets'
module Peaberry
class DotJs
def initialize
@sprockets = Sprockets::Environment.new
dot_js_dir = File.expand_path('~/.js')
@sprockets.append_path(dot_js_dir)
end
def call(env)
headers = Rack::Ut... |
Create placeholder JS manifest file. | # frozen_string_literal: true
require "thor/group"
module Combustion
class Generator < Thor::Group
include Thor::Actions
def self.source_root
File.expand_path File.join(File.dirname(__FILE__), "..", "..")
end
def create_directories
empty_directory "spec/internal"
empty_directory ... | # frozen_string_literal: true
require "thor/group"
module Combustion
class Generator < Thor::Group
include Thor::Actions
def self.source_root
File.expand_path File.join(File.dirname(__FILE__), "..", "..")
end
def create_directories
empty_directory "spec/internal"
empty_directory ... |
Remove newline escape before method - (ruby1.8) | require 'spec_helper'
describe 'munin::master', :type => 'class' do
context 'default' do
include_context :Debian
it { should compile }
it {
should contain_package('munin')
should contain_file('/etc/munin/munin.conf')\
.with_content(/^graph_strategy cgi$/)
}
end
context 'with... | require 'spec_helper'
describe 'munin::master', :type => 'class' do
context 'default' do
include_context :Debian
it { should compile }
it {
should contain_package('munin')
should contain_file('/etc/munin/munin.conf')
.with_content(/^graph_strategy cgi$/)
}
end
context 'with ... |
Watch for updates on port 3124. | require 'rubygems'
require 'sinatra'
require 'json'
set :port, 3123
set :environment, :production
enable :lock
Dir.chdir(File.dirname(__FILE__) + "/..")
post "/" do
puts "Recieved payload!"
puts "Rev: #{`git name-rev HEAD`.strip}"
system %{rake handle_update --trace REF=#{JSON.parse(params["payload"])["ref"].ins... | require 'rubygems'
require 'sinatra'
require 'json'
set :port, 3124
set :environment, :production
enable :lock
Dir.chdir(File.dirname(__FILE__) + "/..")
post "/" do
puts "Recieved payload!"
puts "Rev: #{`git name-rev HEAD`.strip}"
system %{rake handle_update --trace REF=#{JSON.parse(params["payload"])["ref"].ins... |
Update Cocoapods Spec to be 1.5 | Pod::Spec.new do |s|
s.name = 'SVGgh'
s.version = '1.4.0'
s.license = 'MIT'
s.tvos.deployment_target = '9.0'
s.ios.deployment_target = '7.0'
s.summary = "SVG Rendering Library for iOS"
s.homepage = 'https://github.com/GenerallyHelpfulSoftware/SVGgh'
s.author = { 'Glenn R. Howes' => 'glenn@genhelp... | Pod::Spec.new do |s|
s.name = 'SVGgh'
s.version = '1.5'
s.license = 'MIT'
s.tvos.deployment_target = '9.0'
s.ios.deployment_target = '7.0'
s.summary = "SVG Rendering Library for iOS"
s.homepage = 'https://github.com/GenerallyHelpfulSoftware/SVGgh'
s.author = { 'Glenn R. Howes' => 'glenn@genhelp.c... |
Swap out the raw SQL for ActiveRecord stuff | class Admin::LeaderboardController < AdminController
def index
sql = "SELECT COUNT(*) AS activity_count, (SELECT users.username FROM users WHERE users.id = activities.actor_id) FROM activities WHERE activities.actor_type = 'User' GROUP BY actor_id ORDER BY activity_count DESC LIMIT 200"
values = ActiveRecord:... | class Admin::LeaderboardController < AdminController
def index
counts = Activity.where(actor_type: 'User').
group(:actor_id).
order('count_all DESC').
limit(200).
count
@data = counts.map do |user_id, count|
user = User.find(user_id)
{
user: user,
activity... |
Add support for Sidekiq 5.0 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sidekiq/pool/version'
Gem::Specification.new do |spec|
spec.name = 'sidekiq-pool'
spec.version = Sidekiq::Pool::VERSION
spec.authors = ['Laurynas Butkus']
spec.email ... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sidekiq/pool/version'
Gem::Specification.new do |spec|
spec.name = 'sidekiq-pool'
spec.version = Sidekiq::Pool::VERSION
spec.authors = ['Laurynas Butkus']
spec.email ... |
Update gemspec with current date | Gem::Specification.new do |s|
s.name = "wkhtmltopdf-heroku"
s.version = "2.12.2.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_ruby_version = '>= 1.8.7'
s.authors = ["Brad Phelan"]
s.date = "2015-03-19"
s.description = "wkhtmltopdf b... | Gem::Specification.new do |s|
s.name = "wkhtmltopdf-heroku"
s.version = "2.12.2.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_ruby_version = '>= 1.8.7'
s.authors = ["Brad Phelan"]
s.date = "2015-07-15"
s.description = "wkhtmltopdf b... |
Add the Apple Lossless Audio Codec decoder formula. | require 'formula'
class Alac < Formula
homepage 'http://craz.net/programs/itunes/alac.html'
url 'http://craz.net/programs/itunes/files/alac_decoder-0.2.0.tgz'
md5 'cec75c35f010d36e7bed91935b57f2d1'
def install
system "make", "CFLAGS=#{ENV.cflags}", "CC=#{ENV.cc}"
bin.install('alac')
end
end
| |
Use Ruby 2.0 syntax in pod spec and replace tag with branch | Pod::Spec.new do |s|
s.name = "FootlessParser"
s.version = "1.0"
s.summary = "A simple parser combinator written in Swift"
s.description = "FootlessParser is a simple and pretty naive implementation of a parser combinator in Swift. It enables infinite lookahead, non-ambiguous parsing with err... | Pod::Spec.new do |s|
s.name = 'FootlessParser'
s.version = '1.0'
s.summary = 'A simple parser combinator written in Swift'
s.description = 'FootlessParser is a simple and pretty naive implementation of a parser combinator in Swift. It enables infinite lookahead, non-ambiguous parsing with err... |
Fix Swift version in podspec | Pod::Spec.new do |s|
s.name = "Tabman"
s.platform = :ios, "9.0"
s.requires_arc = true
s.swift_version = "4.2"
s.version = "2.4.1"
s.summary = "A powerful paging view controller with indicator bar."
s.description = <<-DESC
Tabman is a highly customisable, powerful and... | Pod::Spec.new do |s|
s.name = "Tabman"
s.platform = :ios, "9.0"
s.requires_arc = true
s.swift_version = "4.0"
s.version = "2.4.1"
s.summary = "A powerful paging view controller with indicator bar."
s.description = <<-DESC
Tabman is a highly customisable, powerful and... |
Add validation to make repsonse content mandatory | class Response < ActiveRecord::Base
belongs_to :responder, class_name: :User
belongs_to :respondable, polymorphic: true
has_many :votes, as: :votable
def responder_name
user = User.find(self.responder_id)
user.username
end
def count_votes
total = self.votes.sum(:value)
self.update_attribut... | class Response < ActiveRecord::Base
belongs_to :responder, class_name: :User
belongs_to :respondable, polymorphic: true
has_many :votes, as: :votable
validates :content, presence: true
def responder_name
user = User.find(self.responder_id)
user.username
end
def count_votes
total = self.votes... |
Change gemspec to contain README.md | Gem::Specification.new do |s|
s.name = 'haproxy_log_parser'
s.version = IO.read('VERSION').chomp
s.authors = ['Toby Hsieh']
s.homepage = 'https://github.com/tobyhs/haproxy_log_parser'
s.summary = 'Parser for HAProxy logs in the HTTP log format'
s.description = s.summary
s.license = 'MIT'
s.add_dependen... | Gem::Specification.new do |s|
s.name = 'haproxy_log_parser'
s.version = IO.read('VERSION').chomp
s.authors = ['Toby Hsieh']
s.homepage = 'https://github.com/tobyhs/haproxy_log_parser'
s.summary = 'Parser for HAProxy logs in the HTTP log format'
s.description = s.summary
s.license = 'MIT'
s.add_dependen... |
Add common methods from topology controllers to new mixin | module TopologyMixin
def show
# When navigated here without id, it means this is a general view for all providers (not for a specific provider)
# all previous navigation should not be displayed in breadcrumbs as the user could arrive from
# any other page in the application.
@breadcrumbs.clear if para... | |
Fix bad naming of when adding migrations | module SpreeMailChimp
module Generators
class InstallGenerator < Rails::Generators::Base
def add_javascripts
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_mail_chimp\n"
end
def add_stylesheets
inject_into_file "app/assets/stylesheets/store/all.css"... | module SpreeMailChimp
module Generators
class InstallGenerator < Rails::Generators::Base
def add_javascripts
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_mail_chimp\n"
end
def add_stylesheets
inject_into_file "app/assets/stylesheets/store/all.css"... |
Set the version number because linuxbrew thinks it is "Unix" |
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the Lic... |
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the Lic... |
Change URI parse depending on `ascii_only?` | # frozen_string_literal: true
require 'redirect_follow_get/version'
require 'net/http'
module RedirectFollowGet
class TooManyRedirects < StandardError; end
end
def redirect_follow_get(url, limit: 10)
raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero?
uri = URI(URI.escape(url))
... | # frozen_string_literal: true
require 'redirect_follow_get/version'
require 'addressable'
require 'net/http'
module RedirectFollowGet
class TooManyRedirects < StandardError; end
end
def redirect_follow_get(url, limit: 10)
raise RedirectFollowGet::TooManyRedirects, 'too many HTTP redirects' if limit.zero?
uri =... |
Fix `test_case_insensitiveness` to follow up eb5fef5 | # frozen_string_literal: true
require "cases/helper"
class PostgresqlCaseInsensitiveTest < ActiveRecord::PostgreSQLTestCase
class Default < ActiveRecord::Base; end
def test_case_insensitiveness
connection = ActiveRecord::Base.connection
table = Default.arel_table
column = Default.columns_hash["char1... | # frozen_string_literal: true
require "cases/helper"
class PostgresqlCaseInsensitiveTest < ActiveRecord::PostgreSQLTestCase
class Default < ActiveRecord::Base; end
def test_case_insensitiveness
connection = ActiveRecord::Base.connection
attr = Default.arel_attribute(:char1)
comparison = connection.c... |
Change the login URL expectation to a RegExp that takes logindev into account for Travis | Given(/^I am logged in$/) do
ENV['PDS_HANDLE'] = 'PDS_HANDLE'
end
Given(/^I am not logged in$/) do
ENV['PDS_HANDLE'] = nil
end
Then(/^I should a login link$/) do
expect(page).to have_css('.nyu-login i.icons-famfamfam-lock_open')
expect(page).to have_css('.nyu-login a.login')
end
Then(/^I should see "(.*?)" a... | Given(/^I am logged in$/) do
ENV['PDS_HANDLE'] = 'PDS_HANDLE'
end
Given(/^I am not logged in$/) do
ENV['PDS_HANDLE'] = nil
end
Then(/^I should a login link$/) do
expect(page).to have_css('.nyu-login i.icons-famfamfam-lock_open')
expect(page).to have_css('.nyu-login a.login')
end
Then(/^I should see "(.*?)" a... |
Send --unoptimize if Gifsicle level is 0 | require 'image_optim/worker'
class ImageOptim
class Worker
# http://www.lcdf.org/gifsicle/
class Gifsicle < Worker
INTERLACE_OPTION =
option(:interlace, false, 'Turn interlacing on'){ |v| !!v }
LEVEL_OPTION =
option(:level, 3, 'Compression level: '\
'`0` - Does nothing, '\
... | require 'image_optim/worker'
class ImageOptim
class Worker
# http://www.lcdf.org/gifsicle/
class Gifsicle < Worker
INTERLACE_OPTION =
option(:interlace, false, 'Turn interlacing on'){ |v| !!v }
LEVEL_OPTION =
option(:level, 3, 'Compression level: '\
'`0` - Set unoptimazatio... |
Handle case of empty body being rescued | module DeepCover
class Node
class ExceptionCatchVariableAssign < Node
include NodeBehavior::CoverFromParent
end
class Resbody < Node
include NodeBehavior::CoverWithNextInstruction
def suffix # Only called when body is nil
";$_cov[#{context.nb}][#{nb*2}]+=1;nil"
end
... | module DeepCover
class Node
class ExceptionCatchVariableAssign < Node
include NodeBehavior::CoverFromParent
end
class Resbody < Node
include NodeBehavior::CoverWithNextInstruction
def suffix # Only called when body is nil
";$_cov[#{context.nb}][#{nb*2}]+=1;nil"
end
... |
Use of namespace changes in Butterfli Rails | class Butterfli::Instagram::Rails::ApiController < Butterfli::Controller
layout nil
protect_from_forgery with: :null_session, :if => Proc.new { |c| c.request.format == 'application/json' }
protected
def client
@client ||= Butterfli.configuration.providers(:instagram).client
end
end | class Butterfli::Instagram::Rails::ApiController < Butterfli::Rails::Controller
layout nil
protect_from_forgery with: :null_session, :if => Proc.new { |c| c.request.format == 'application/json' }
protected
def client
@client ||= Butterfli.configuration.providers(:instagram).client
end
end |
Bring images controller from spree_backend so we can merge it with ofn's decorator | module Spree
module Admin
class ImagesController < ResourceController
before_filter :load_data
create.before :set_viewable
update.before :set_viewable
destroy.before :destroy_before
private
def location_after_save
admin_product_images_url(@product)
end
... | |
Fix download link in test recipe | node.set['java']['jdk_version'] = 6
node.set['jetty']['port'] = 8080
node.set['jetty']['version'] = '8.1.10.v20130312'
node.set['jetty']['link'] = 'http://eclipse.org/downloads/download.php?file=/jetty/stable-8/dist/jetty-distribution-8.1.10.v20130312.tar.gz&r=1'
node.set['jetty']['checksum'] = 'e966f87823adc323ce67e9... | node.set['java']['jdk_version'] = 6
node.set['jetty']['port'] = 8080
node.set['jetty']['version'] = '8.1.10.v20130312'
node.set['jetty']['link'] = 'http://eclipse.org/downloads/download.php?file=/jetty/8.1.10.v20130312/dist/jetty-distribution-8.1.10.v20130312.tar.gz&r=1'
node.set['jetty']['checksum'] = 'e966f87823adc3... |
Add a "live" gemspec for production builds | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "metasploit_data_models/version"
Gem::Specification.new do |s|
s.name = "metasploit_data_models"
s.version = "0.0.2.43DEV" # This gemspec is linked to metasploit releases and follows trunk
s.authors = ["... | |
Change to Tag Index descending | class TagsController < ApplicationController
before_action :require_user
before_action :set_current_tab, only: [:index, :show]
def index
@tags = Tag.order(name: :desc)
end
def show
@tag = Tag.find(params[:id])
@taggings = get_taggings(@tag)
end
def get_taggings(tag)
tags = {}
tag.... | class TagsController < ApplicationController
before_action :require_user
before_action :set_current_tab, only: [:index, :show]
def index
@tags = Tag.order(:name)
end
def show
@tag = Tag.find(params[:id])
@taggings = get_taggings(@tag)
end
def get_taggings(tag)
tags = {}
tag.taggin... |
Update migrations to support Rails 5.1 | class AddUnconfirmedEmailToSpreeUsers < ActiveRecord::Migration[5.2]
def change
unless column_exists?(:spree_users, :unconfirmed_email)
add_column :spree_users, :unconfirmed_email, :string
end
end
end
| class AddUnconfirmedEmailToSpreeUsers < SolidusSupport::Migration[5.1]
def change
unless column_exists?(:spree_users, :unconfirmed_email)
add_column :spree_users, :unconfirmed_email, :string
end
end
end
|
Return ‘large’ image version as default url. | collection @images
node(:url) { |p| p.file.url }
node(:thumbnail_url) { |p| p.file.thumbnail.url }
attribute :description
| collection @images
node(:url) { |p| p.file.large.url }
node(:thumbnail_url) { |p| p.file.thumbnail.url }
attribute :description
|
Stop requiring rubygems, for those folks who don't use it | require 'rubygems'
require 'activesupport'
require 'nokogiri'
require 'uri'
require 'active_api/builder'
require 'active_api/has_definition'
require 'active_api/collection'
require 'active_api/complex_type'
require 'active_api/simple_type'
require 'active_api/field'
require 'active_api/schema'
require 'active_api/def... | require 'active_support'
require 'nokogiri'
require 'uri'
require 'active_api/builder'
require 'active_api/has_definition'
require 'active_api/collection'
require 'active_api/complex_type'
require 'active_api/simple_type'
require 'active_api/field'
require 'active_api/schema'
require 'active_api/definition'
|
Stop using Ruby 2.0 keyword arguments completely | require 'httparty'
require 'nokogiri'
module Snoop
class Http
UrlRequiredException = Class.new(StandardError)
DEFAULT_OPTIONS = {
delay: 0,
count: 1,
while: -> { false },
until: -> { true }
}
attr_reader :url, :css, :http_client
attr_accessor :content
def initialize... | require 'httparty'
require 'nokogiri'
module Snoop
class Http
UrlRequiredException = Class.new(StandardError)
DEFAULT_INIT_OPTIONS = {
url: nil,
css: nil,
http_client: HTTParty
}
DEFAULT_NOTIFY_OPTIONS = {
delay: 0,
count: 1,
while: -> { false },
until: -> ... |
Modify to return empty array if consul kv parameters are nil. | # -*- coding: utf-8 -*-
# Copyright 2014 TIS Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | # -*- coding: utf-8 -*-
# Copyright 2014 TIS Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... |
Fix bug from improper handling of raketask string | module Postamt
class Railtie < Rails::Railtie
railtie_name "postamt"
attr_accessor :running_in_rake
rake_tasks do
self.running_in_rake = true
end
initializer "postamt.hook", before: "active_record.initialize_database" do |app|
if self.running_in_rake
# We mustn't hook into AR... | module Postamt
class Railtie < Rails::Railtie
railtie_name "postamt"
attr_accessor :running_in_rake
rake_tasks do
self.running_in_rake = true
end
initializer "postamt.hook", before: "active_record.initialize_database" do |app|
if self.running_in_rake
# We mustn't hook into AR... |
Add konacha as a dependency | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ember/konacha/rails/version'
Gem::Specification.new do |spec|
spec.name = "ember-konacha-rails"
spec.version = Ember::Konacha::Rails::VERSION
spec.authors = ["Kristian ... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ember/konacha/rails/version'
Gem::Specification.new do |spec|
spec.name = "ember-konacha-rails"
spec.version = Ember::Konacha::Rails::VERSION
spec.authors = ["Kristian ... |
Add missing dep on rom to changeset | require File.expand_path('../lib/rom/changeset/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = 'rom-changeset'
gem.summary = 'Changeset abstraction for rom-rb'
gem.description = 'rom-changeset adds support for preprocessing data on top of rom-rb repositories'
gem.author =... | require File.expand_path('../lib/rom/changeset/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = 'rom-changeset'
gem.summary = 'Changeset abstraction for rom-rb'
gem.description = 'rom-changeset adds support for preprocessing data on top of rom-rb repositories'
gem.author =... |
Add spec tests for postfix_instance | require 'spec_helper_acceptance'
require 'pry'
describe 'postfix_instance' do
before :all do
# include postfix class for package installation
apply_manifest('include postfix', :catch_failures => true)
end
describe "getting a list of instances via puppet ressource" do
describe command('puppet resou... | require 'spec_helper_acceptance'
require 'pry'
describe 'postfix_instance' do
before :all do
# include postfix class for package installation
apply_manifest('include postfix', :catch_failures => true)
apply_manifest('include postfix', :catch_changes => true)
end
describe "get existing instances" do
... |
Fix ActivityObject obsolete column info | class CreateActivityObjectAudiences < ActiveRecord::Migration
def change
create_table :activity_object_audiences do |t|
t.references :activity_object
t.references :relation
t.timestamps
end
add_foreign_key :activity_object_audiences, :activity_objects, :name => 'activity_object_audienc... | class CreateActivityObjectAudiences < ActiveRecord::Migration
def change
create_table :activity_object_audiences do |t|
t.references :activity_object
t.references :relation
t.timestamps
end
add_foreign_key :activity_object_audiences, :activity_objects, :name => 'activity_object_audienc... |
Manage sandbox test resources in setup/teardown | require "testing_env"
require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
skip "sandbox not implemented" unless Sandbox.available?
end
def test_allow_write
s = Sandbox.new
testpath = Pathname.new(TEST_TMPDIR)
foo = testpath/"foo"
s.allow_write foo
s.exec "touch", foo
a... | require "testing_env"
require "sandbox"
class SandboxTest < Homebrew::TestCase
def setup
skip "sandbox not implemented" unless Sandbox.available?
@sandbox = Sandbox.new
@dir = Pathname.new(Dir.mktmpdir)
@file = @dir/"foo"
end
def teardown
@dir.rmtree
end
def test_allow_write
@sandbo... |
Add test to never break the app.json file again. | # frozen_string_literal: true
require "rails_helper"
require "yaml"
require "json"
require "pathname"
describe "app.json" do
it "loads from JSON" do
assert JSON.load(File.open(Rails.root.join("app.json")))
end
end
describe "locales" do
yaml_paths = Pathname.glob(Rails.root.join("config", "locales", "*.yml"... | |
Update KDEBase Runtime to 1.4.0 and fix homepage. | require 'formula'
class KdebaseRuntime <Formula
url 'ftp://ftp.kde.org/pub/kde/stable/4.4.2/src/kdebase-runtime-4.4.2.tar.bz2'
homepage ''
md5 'd46fca58103624c28fcdf3fbd63262eb'
depends_on 'cmake' => :build
depends_on 'kde-phonon'
depends_on 'oxygen-icons'
def install
phonon = Formula.factory 'kde-... | require 'formula'
class KdebaseRuntime <Formula
url 'ftp://ftp.kde.org/pub/kde/stable/4.5.2/src/kdebase-runtime-4.5.2.tar.bz2'
homepage 'http://www.kde.org/'
md5 '6503a445c52fc1055152d46fca56eb0a'
depends_on 'cmake' => :build
depends_on 'kde-phonon'
depends_on 'oxygen-icons'
def install
phonon = Fo... |
Use random string in name of domain | module VagrantPlugins
module ProviderLibvirt
module Action
# Setup name for domain and domain volumes.
class SetNameOfDomain
def initialize(app, env)
@app = app
end
def call(env)
env[:domain_name] = env[:root_path].basename.to_s.dup
env[:domain_n... | module VagrantPlugins
module ProviderLibvirt
module Action
# Setup name for domain and domain volumes.
class SetNameOfDomain
def initialize(app, env)
@app = app
end
def call(env)
require 'securerandom'
env[:domain_name] = env[:root_path].basename... |
Add base hostname configuration for swagger initializer | require "swagger/blocks"
module ApiFlashcards
include Swagger::Blocks
swagger_root do
key :swagger, "2.0"
info do
key :version, "1.0.0"
key :title, "Flashcards API"
key :description, "A sample API for Flashcards App"
end
tag do
key :name, "Cards"
end
tag do
key... | require "swagger/blocks"
module ApiFlashcards
include Swagger::Blocks
host = if ENV['RAILS_ENV'] == "production"
"https://mkdev-flashcards.herokuapp.com"
else
"localhost:3000"
end
swagger_root do
key :swagger, "2.0"
info do
key :version, "1.0.0"
key :title, "Flashcards API"
... |
Upgrade IntelliJ CE EAP to version 14 (build 138.777). | class IntellijIdeaCommunityEap < Cask
url 'http://download.jetbrains.com/idea/ideaIC-135.863.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
version '135.863'
sha256 '623aac77c3fea84ca6677d5777f7c1c72e3cd5b0ba680d3a465452767e78db89'
link 'IntelliJ IDEA 13 CE EAP.app'
end
| class IntellijIdeaCommunityEap < Cask
url 'http://download.jetbrains.com/idea/ideaIC-138.777.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
version '138.777'
sha256 '9614d8055051dc418bce905587c33b3d30e164d1eb873d3716b613627a2c52a2'
link 'IntelliJ IDEA 14 CE EAP.app'
end
|
Remove warning "instance variable not initialized" | module Redisse
module Server::Redis
def redis
@redis ||= EM::Hiredis.connect(redisse.redis_server)
end
def pubsub(&on_disconnected)
ensure_pubsub
return false unless @pubsub.connected?
@pubsub_errbacks << on_disconnected
true
end
def ensure_pubsub
return if @p... | module Redisse
module Server::Redis
def redis
@redis ||= EM::Hiredis.connect(redisse.redis_server)
end
def pubsub(&on_disconnected)
ensure_pubsub
return false unless @pubsub.connected?
@pubsub_errbacks << on_disconnected
true
end
def ensure_pubsub
return if de... |
Simplify error handling so we catch every bad response | require 'rubygems'
require 'zlib'
require 'archive/tar/minitar'
require 'stringio'
require 'rest_client'
module Relish
module Command
class Push < Base
def default
run
end
def run
post files_as_tar_gz
end
def post(tar_gz_data)
resourc... | require 'rubygems'
require 'zlib'
require 'archive/tar/minitar'
require 'stringio'
require 'rest_client'
module Relish
module Command
class Push < Base
def default
run
end
def run
post files_as_tar_gz
end
def post(tar_gz_data)
resourc... |
Update Join Together to 7.5.1 | cask :v1 => 'join-together' do
version '7.5.0'
sha256 'a6661c05b73fff78e1fcfc4e474e95f732ccc996a5bbae56f390e51a414e6867'
url "http://dougscripts.com/itunes/scrx/jointogether#{version.delete('.')}.zip"
name 'Join Together'
appcast 'http://dougscripts.com/itunes/itinfo/jointogether_appcast.xml',
:sha... | cask :v1 => 'join-together' do
version '7.5.1'
sha256 '116365cb1dae0b3c3a00a90f357e1d154767e6d866e5e18cd32ab3d3f7698d30'
url "http://dougscripts.com/itunes/scrx/jointogether#{version.delete('.')}.zip"
name 'Join Together'
appcast 'http://dougscripts.com/itunes/itinfo/jointogether_appcast.xml',
:sha... |
Add Fedora 17+ NFS support. | require 'pathname'
module Vagrant
module Hosts
class Fedora < Linux
def self.match?
release_file = Pathname.new("/etc/redhat-release")
if release_file.exist?
release_file.open("r") do |f|
return true if f.gets =~ /^Fedora/
end
end
false
... | require 'pathname'
module Vagrant
module Hosts
class Fedora < Linux
def self.match?
release_file = Pathname.new("/etc/redhat-release")
if release_file.exist?
release_file.open("r") do |f|
return true if f.gets =~ /^Fedora/
end
end
false
... |
Simplify password usage for mysql client | passwords = EncryptedPasswords.new(node, node["percona"]["encrypted_data_bag"])
replication_sql = "/etc/mysql/replication.sql"
server = node.percona.server
# define access grants
template replication_sql do
source "replication_#{server.role}.sql.erb"
variables(replication_password: passwords.replication_password)
... | require 'shellwords'
passwords = EncryptedPasswords.new(node, node["percona"]["encrypted_data_bag"])
replication_sql = "/etc/mysql/replication.sql"
server = node.percona.server
# define access grants
template replication_sql do
source "replication_#{server.role}.sql.erb"
variables(replication_password: passwords.... |
Fix comment in SlimLint hook | module Overcommit::Hook::PreCommit
# Runs `slim-lint` against any modified HAML files.
class SlimLint < Base
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
type.include?('W') ? :warning : :error
end
def run
result = execute(command + applicable_files)
return :pass if result.success?
... | module Overcommit::Hook::PreCommit
# Runs `slim-lint` against any modified Slim templates.
class SlimLint < Base
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
type.include?('W') ? :warning : :error
end
def run
result = execute(command + applicable_files)
return :pass if result.success?
... |
Fix simplecov version (workaround for a bug in CodeClimate reporter) | # frozen_string_literal: true
require_relative 'lib/jenkins/peace/version'
Gem::Specification.new do |s|
s.name = 'jenkins-peace'
s.version = Jenkins::Peace::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Nicolas Rodriguez']
s.email = ['nrodriguez@jbox-web.com']
s.homepage ... | # frozen_string_literal: true
require_relative 'lib/jenkins/peace/version'
Gem::Specification.new do |s|
s.name = 'jenkins-peace'
s.version = Jenkins::Peace::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Nicolas Rodriguez']
s.email = ['nrodriguez@jbox-web.com']
s.homepage ... |
Uninstall aws-iam-authenticator to use awscli instead | ghg 'CircleCI-Public/circleci-cli' do
cli_name 'circleci'
end
ghg 'c-bata/kube-prompt'
ghg 'golang/dep'
ghg 'hyperhq/pi'
ghg 'kubernetes-sigs/aws-iam-authenticator'
ghg 'mattn/memo'
ghg 'wantedly/dockertags'
| ghg 'CircleCI-Public/circleci-cli' do
cli_name 'circleci'
end
ghg 'c-bata/kube-prompt'
ghg 'golang/dep'
ghg 'hyperhq/pi'
ghg 'mattn/memo'
ghg 'wantedly/dockertags'
|
Enable to fetch stories in activities | module PivotalTracker
class Activity
include HappyMapper
class << self
def all(project=nil, options={})
params = self.encode_options(options)
if project
parse(Client.connection["/projects/#{project.id}/activities#{params}"].get)
else
parse(Client.connection["/... | module PivotalTracker
class Activity
include HappyMapper
class << self
def all(project=nil, options={})
params = self.encode_options(options)
if project
parse(Client.connection["/projects/#{project.id}/activities#{params}"].get)
else
parse(Client.connection["/... |
Add spec for dhis2 links helper | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Dhis2Helper, type: :helper do
let(:project) { double(dhis2_url: "https://sample.org/dhis2") }
it "links to dhis2 dataset" do
expect(helper.link_to_dataset(project, "dsid")).to eq(
'<a target="_blank" class="external" '\
'href="... | |
Replace the configuration class variable with an instance variable equivalant | require "email_assessor/email_validator"
module EmailAssessor
def self.domain_is_disposable?(domain)
domain_in_file?(domain, configuration.disposable_domains_file_name)
end
def self.domain_is_blacklisted?(domain)
domain_in_file?(domain, configuration.blacklisted_domains_file_name)
end
def self.conf... | require "email_assessor/email_validator"
module EmailAssessor
def self.domain_is_disposable?(domain)
domain_in_file?(domain, configuration.disposable_domains_file_name)
end
def self.domain_is_blacklisted?(domain)
domain_in_file?(domain, configuration.blacklisted_domains_file_name)
end
def self.conf... |
Fix image size on webview | class WebViewController < UIViewController
attr_accessor :item
def viewDidLoad
super
self.navigationItem.title = self.item[3]
@webview = UIWebView.new.tap do |v|
scrollwindow = UIScrollView.alloc.initWithFrame(UIScreen.mainScreen.bounds)
scrollwindow.scrollEnabled = true
scrollwindow.... | class WebViewController < UIViewController
attr_accessor :item
def viewDidLoad
super
self.navigationItem.title = self.item[3]
@webview = UIWebView.new.tap do |v|
scrollwindow = UIScrollView.alloc.initWithFrame(UIScreen.mainScreen.bounds)
scrollwindow.scrollEnabled = true
scrollwindow.... |
Fix user model with new authentication | require 'acts_as_indexed'
begin
Refinery::User.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:username, :email]
end
rescue NameError
end
| require 'acts_as_indexed'
begin
Refinery::Authentication::Devise::User.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:username, :email]
end
rescue NameError
end |
Set a specific minimum version of rspec | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/temando/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jason Stirk"]
gem.email = ["jason@reinteractive.net"]
gem.description = %q{Ruby API to Temando - an Australian transport fulfilment broker}
gem.summary = ... | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/temando/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jason Stirk"]
gem.email = ["jason@reinteractive.net"]
gem.description = %q{Ruby API to Temando - an Australian transport fulfilment broker}
gem.summary = ... |
Use Model.table_name to take into account the table_name_prefix | module Regressor
module Model
module Database
module Index
def indices
::ActiveRecord::Base.connection.indexes(@model.tableize.gsub("/", "_")).map do |indexes|
"it { is_expected.to have_db_index #{indexes.columns} }"
end.flatten.join("\n ")
end
end
... | module Regressor
module Model
module Database
module Index
def indices
::ActiveRecord::Base.connection.indexes(@model.constantize.table_name).map do |indexes|
"it { is_expected.to have_db_index #{indexes.columns} }"
end.flatten.join("\n ")
end
end
e... |
Verify octokit gem in changelog fetcher | require 'octokit'
module Fastlane
module Helper
class ChangelogGeneratorFetcher
def self.fetch_labels(project, base_branch, access_token)
Octokit.auto_paginate = true
issues_map = {}
Octokit.issues(project, state: 'closed', access_token: access_token).each do |issue|
issu... | require 'octokit'
module Fastlane
module Helper
class ChangelogGeneratorFetcher
def self.fetch_labels(project, base_branch, access_token)
Actions.verify_gem!('octokit')
Octokit.auto_paginate = true
issues_map = {}
Octokit.issues(project, state: 'closed', access_token: acce... |
Arrange dependencies in alpbhetical order | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'razorpay/constants'
Gem::Specification.new do |spec|
spec.name = 'razorpay'
spec.version = Razorpay::VERSION
spec.authors = ['Abhay Rana', 'Harman Singh']
spec.email = ['nemo... | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'razorpay/constants'
Gem::Specification.new do |spec|
spec.name = 'razorpay'
spec.version = Razorpay::VERSION
spec.authors = ['Abhay Rana', 'Harman Singh']
spec.email = ['nemo... |
Add spec for MongoDB wrapper | $:.unshift('lib').uniq!
require 'perpetuity/mongodb'
module Perpetuity
describe MongoDB do
let(:mongo) { MongoDB.new db: 'perpetuity_gem_test' }
let(:klass) { String }
subject { mongo }
it 'is not connected when instantiated' do
mongo.should_not be_connected
end
it 'connects to its ho... | |
Add myself to authors in podspec | Pod::Spec.new do |spec|
spec.name = 'PeerTalk'
spec.version = '0.1.0'
spec.license = { :type => 'MIT', :file => 'LICENSE.txt' }
spec.homepage = 'http://rsms.me/peertalk/'
spec.authors = { 'Rasmus Andersson' => 'rasmus@notion.se' }
spec.summary = 'iOS and OS X Cocoa library for communicat... | Pod::Spec.new do |spec|
spec.name = 'PeerTalk'
spec.version = '0.1.0'
spec.license = { :type => 'MIT', :file => 'LICENSE.txt' }
spec.homepage = 'http://rsms.me/peertalk/'
spec.authors = {
'Rasmus Andersson' => 'rasmus@notion.se',
'Jonathan Dann' => 'jonathan@jonathandann.com'... |
Add missing timestamps for spree_* tables | class AddMissingTimestampColumns < ActiveRecord::Migration
def change
# Missing updated_at
add_column :friendly_id_slugs, :updated_at, :datetime, null: true
# Missing created_at
add_column :spree_countries, :created_at, :datetime, null: true
add_column :spree_states, :created_at, :datetime, null:... | |
Update Podspec to contain documentation URL | Pod::Spec.new do |s|
s.platform = :ios, "8.0"
s.name = "RQVisual"
s.version = "1.0.0"
s.summary = "A tool for laying out views in code."
s.description = <<-DESC
Visual is a tool for laying out views in code using a visual
style formats similar to... | Pod::Spec.new do |s|
s.platform = :ios, "8.0"
s.name = "RQVisual"
s.version = "1.0.0"
s.summary = "A tool for laying out views in code."
s.description = <<-DESC
Visual is a tool for laying out views in code using a visual
s... |
Update dependencies to require compass 1 and jekyll 2 |
Gem::Specification.new do |s|
s.name = 'jekyll-compass'
s.version = '1.2.0.pre'
s.summary = "Jekyll generator plugin to build Compass projects during site build"
s.description = <<-EOF
This project is a plugin for the Jekyll static website generator to allow for using Compass projects ... |
Gem::Specification.new do |s|
s.name = 'jekyll-compass'
s.version = '1.2.0.pre'
s.summary = "Jekyll generator plugin to build Compass projects during site build"
s.description = <<-EOF
This project is a plugin for the Jekyll static website generator to allow for using Compass projects ... |
Define key if not defined | module Cassandrb
module Model
module Persistence
extend ActiveSupport::Concern
extend ActiveSupport::Autoload
module InstanceMethods
def save(*args)
self.key= SimpleUUID::UUID.new.to_s unless self.key.nil?
self.client.insert(self.column_family, self.key, self.attrib... | module Cassandrb
module Model
module Persistence
extend ActiveSupport::Concern
extend ActiveSupport::Autoload
module InstanceMethods
def save(*args)
self.key= SimpleUUID::UUID.new.to_s if self.key.nil?
self.client.insert(self.column_family, self.key, self.attributes... |
Fix Voice::Encoder volume option for avconv | require 'opus-ruby'
# Discord voice chat support
module Discordrb::Voice
# Wrapper class around opus-ruby
class Encoder
attr_accessor :volume, :use_avconv
def initialize
@sample_rate = 48_000
@frame_size = 960
@channels = 2
@volume = 1.0
@opus = Opus::Encoder.new(@sample_rate... | require 'opus-ruby'
# Discord voice chat support
module Discordrb::Voice
# Wrapper class around opus-ruby
class Encoder
attr_accessor :volume, :use_avconv
def initialize
@sample_rate = 48_000
@frame_size = 960
@channels = 2
@volume = 1.0
@opus = Opus::Encoder.new(@sample_rate... |
Use display_amount instead of display_total | module KlarnaGateway
module AmountCalculators::UK
class LineItemCalculator
def adjust_with(line_item)
yield().merge({
total_tax_amount: total_tax_amount(line_item),
tax_rate: tax_rate(line_item),
unit_price: unit_price(line_item),
total_amount: total_amount(li... | module KlarnaGateway
module AmountCalculators::UK
class LineItemCalculator
def adjust_with(line_item)
yield().merge({
total_tax_amount: total_tax_amount(line_item),
tax_rate: tax_rate(line_item),
unit_price: unit_price(line_item),
total_amount: total_amount(li... |
Make sure we're passing in DateTimes to importers that expect datetimes | class CsvRowCleaner < Struct.new :csv_row
def transform_row
if has_dates
date_header = (csv_row.headers & date_headers)[0]
csv_row[date_header] = Date.parse(csv_row[date_header])
end
return csv_row
end
def has_dates
(csv_row.headers & date_headers).present?
end
def date_headers
... | class CsvRowCleaner < Struct.new :csv_row
def transform_row
if has_dates
date_header = (csv_row.headers & date_headers)[0]
csv_row[date_header] = DateTime.parse(csv_row[date_header])
end
return csv_row
end
def has_dates
(csv_row.headers & date_headers).present?
end
def date_head... |
Fix error when there is no current_user | class AdminController < ActionController::Base
include PermissionsHelper
include SessionHelpers
# skip_before_action :verify_authenticity_token, raise: false
before_action :ensure_admin_user
before_action :set_admin_base_breadcrumbs
before_action :set_user_gon
layout 'admin'
def ensure_only_admin_user... | class AdminController < ActionController::Base
include PermissionsHelper
include SessionHelpers
# skip_before_action :verify_authenticity_token, raise: false
before_action :ensure_admin_user
before_action :set_admin_base_breadcrumbs
before_action :set_user_gon
layout 'admin'
def ensure_only_admin_user... |
Make sure root element is not being returned | # Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper
# Enable parameter wrapping for JSON.
# ActiveSupport.on_load(:action_controller) do
# wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
# end
# To enable root element in JS... | # Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper
# Enable parameter wrapping for JSON.
# ActiveSupport.on_load(:action_controller) do
# wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
# end
# To enable root element in JS... |
Fix for latest rails edge | # wrap find_template to search in ActiveScaffold paths when template is missing
module ActionView #:nodoc:
class PathSet
attr_accessor :active_scaffold_paths
def find_template_with_active_scaffold(original_template_path, format = nil)
begin
find_template_without_active_scaffold(original_templat... | # wrap find_template to search in ActiveScaffold paths when template is missing
module ActionView #:nodoc:
class PathSet
attr_accessor :active_scaffold_paths
def find_template_with_active_scaffold(original_template_path, format = nil, html_fallback = true)
begin
find_template_without_active_sca... |
Add license to gemspec, is MIT | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/rails_stdout_logging/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["David Dollar", "Jonathan Dance", "Richard Schneeman"]
gem.email = ["david@heroku.com", "jd@heroku.com", "richard@heroku.com"]
gem.description = %q{Se... | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/rails_stdout_logging/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["David Dollar", "Jonathan Dance", "Richard Schneeman"]
gem.email = ["david@heroku.com", "jd@heroku.com", "richard@heroku.com"]
gem.description = %q{Se... |
Add tests for all methods | require './hero'
describe Hero do
it "has capitalized name" do
hero = Hero.new 'mike'
expect(hero.name).to eq 'Mike'
end
it "can power up" do
hero = Hero.new 'mike'
expect(hero.power_up).to eq 110
end
end | require './hero'
describe Hero do
it "has capitalized name" do
hero = Hero.new 'mike'
expect(hero.name).to eq 'Mike'
end
it "can power up" do
hero = Hero.new 'mike'
expect(hero.power_up).to eq 110
end
it "can power down" do
hero = Hero.new 'mike'
expect(hero.power_down).to eq 90
e... |
Change controller to API and desired responses to JSON objs | class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
| class ApplicationController < ActionController::API
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :exception
include ActionController::Serialization
end
|
Remove SECRET_TOKEN and calculate a new one | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary atta... | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary atta... |
Add url to growl test file; update code | require 'growl'
Growl.notify {
self.message = "<a href='http://www.google.com'>This is a test!</a>"
self.icon = :Safari
sticky!
}
| require 'rubygems'
require 'bundler/setup'
require 'growl'
notify = Growl.new
notify.title = "Hello, World!"
notify.message = "This is a message to you!"
notify.url = "https://google.com"
notify.run
|
Disable my weird, custom head request response | module Sinatra
module TreeStats
module Routing
module General
def self.registered(app)
app.head '/' do
status :ok
body ""
end
app.get '/' do
# Total uploads
# Disabled until I have time to cache this route
# @... | module Sinatra
module TreeStats
module Routing
module General
def self.registered(app)
app.get '/' do
# Total uploads
# Disabled until I have time to cache this route
# @total_uploads = redis
# .keys("uploads:daily:*")
# .coll... |
Add Hero factory for tests | FactoryGirl.define do
factory :map do
name "Dorado"
map_type "escort"
end
factory :map_segment do
map
name "Attacking: Payload 1"
end
end
| FactoryGirl.define do
factory :hero do
name 'McCree'
role 'offense'
end
factory :map do
name 'Dorado'
map_type 'escort'
end
factory :map_segment do
map
name 'Attacking: Payload 1'
end
end
|
Add Title of PR to output | MILESTONE = 36
ACCESS_TOKEN = "your github access token"
require 'octokit'
o = Octokit::Client.new(:access_token => ACCESS_TOKEN)
results = []
page = 1
loop do
response = o.issues("ManageIQ/manageiq", :milestone => MILESTONE, :state => "closed", :page => page)
break if response == []
results += response
page... | MILESTONE = 36
ACCESS_TOKEN = "your github access token"
require 'octokit'
o = Octokit::Client.new(:access_token => ACCESS_TOKEN)
results = []
page = 1
loop do
response = o.issues("ManageIQ/manageiq", :milestone => MILESTONE, :state => "closed", :page => page)
break if response == []
results += response
page... |
Extend the test recipe a bit | tomcat_install 'helloworld' do
version '8.0.32'
end
tomcat_service 'helloworld' do
action :start
end
| tomcat_install 'helloworld' do
version '8.0.32'
exclude_examples false
end
tomcat_service 'helloworld' do
action :start
env_vars [{ 'CATALINA_PID' => '/opt/tomcat_helloworld/bin/helloworld.pid' }]
end
|
Add a rake task to detect tags without propositions | namespace :analysis do
task :tags_without_propositions => :environment do
Election.all.each do |election|
puts "=> #{election.name}"
election.election_tags.each do |election_tag|
propositions = Proposition.where(:tag_ids.in => [election_tag.tag.id], :candidacy_id.in => election.candidacies.co... | |
Fix field types and remove array defaults in fitness professional profiles migration | class CreateFitnessProfessionalProfiles < ActiveRecord::Migration
def change
create_table :fitness_professional_profiles do |t|
t.string :ethnicity
t.string :training_location
t.text :client_space_descrip
t.text :independent_facility_descrip
t.text :membership_facility_descrip
... | class CreateFitnessProfessionalProfiles < ActiveRecord::Migration
def change
create_table :fitness_professional_profiles do |t|
t.string :ethnicity
t.text :training_location, array: true
t.text :client_space_descrip
t.text :independent_facility_descrip
t.text :membership_facility_de... |
Revert "Set invalid username to ensure testing on circle ci" | require 'application_system_test_case'
class UsersTest < ApplicationSystemTestCase
test 'visiting the index' do
visit users_url
assert_selector 'h1', text: 'The User'
end
end
| require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
test "visiting the index" do
visit users_url
assert_selector "h1", text: "User"
end
end
|
Remove whitespace and commented out code. | require 'sinatra'
class ChefApp < Sinatra::Base
get '/' do
erb :index
end
end
#ChefApp.run!
| require 'sinatra'
class ChefApp < Sinatra::Base
get '/' do
erb :index
end
end
|
Add 2 requires in order to fix apps in the test environment. One require on sass should not be needed and should be investigated. |
require "config/routes"
require "rich/cms/actionpack"
require "rich/cms/engine"
require "rich/cms/content/group"
require "rich/cms/content/item"
| require 'jzip'
require 'sass/plugin'
require "config/routes"
require "rich/cms/actionpack"
require "rich/cms/engine"
require "rich/cms/content/group"
require "rich/cms/content/item"
|
Remove unused code to check for RBX | %w{
future-resource
logger
girl_friday
countdownlatch
celluloid/io
}.each { |f| require f }
class Logger
alias :trace :debug
end
module RubyAMI
def self.new_uuid
SecureRandom.uuid
end
def self.rbx?
RbConfig::CONFIG['RUBY_INSTALL_NAME'] == 'rbx'
end
end
%w{
core_ext/celluloid
action... | %w{
future-resource
logger
girl_friday
countdownlatch
celluloid/io
}.each { |f| require f }
class Logger
alias :trace :debug
end
module RubyAMI
def self.new_uuid
SecureRandom.uuid
end
end
%w{
core_ext/celluloid
action
agi_result_parser
async_agi_environment_parser
client
error
event... |
Add a couple keyboard shortcuts | module Keymap
def self.default()
{
'space' => 'NEXT',
'd' => 'DEBUG',
'up' => 'PREV',
'left' => 'PREV',
'pageup' => 'PREV',
'down' => 'NEXT',
'right' => 'NEXT',
'pagedown' => 'NEXT',
'r' => 'RELOAD... | module Keymap
def self.default()
{
'space' => 'NEXT',
'd' => 'DEBUG',
'up' => 'PREV',
'left' => 'PREV',
'pageup' => 'PREV',
'down' => 'NEXT',
'right' => 'NEXT',
'pagedown' => 'NEXT',
'r' => 'RELOAD... |
Mark audit job tests as pending | require 'spec_helper'
describe AuditJob do
before do
@user = FactoryGirl.find_or_create(:jill)
@inbox = @user.mailbox.inbox
@file = GenericFile.new
@file.apply_depositor_metadata(@user)
@file.save
end
after do
@file.delete
end
describe "passing audit" do
it "should not send passin... | require 'spec_helper'
describe AuditJob do
before do
@user = FactoryGirl.find_or_create(:jill)
@inbox = @user.mailbox.inbox
@file = GenericFile.new
@file.apply_depositor_metadata(@user)
@file.save
end
describe "passing audit" do
it "should not send passing mail" do
skip "skipping au... |
Add missing is_closed field to ticket serialiser | class HelpdeskTicketSerializer < ActiveModel::Serializer
attributes :id,
:student,
:task,
:tutorial,
:target_grade,
:description,
:is_resolved,
:created_at,
:resolved_at,
:minutes_to_resolve
has_one... | class HelpdeskTicketSerializer < ActiveModel::Serializer
attributes :id,
:student,
:task,
:tutorial,
:target_grade,
:description,
:is_resolved,
:is_closed,
:created_at,
:resolved_at,
:minu... |
Fix circular dependency while loading Settings | class Settings < ActiveRecord::Base
@instance = first
def self.instance
@instance ||= new
end
end
| class Settings < ActiveRecord::Base
def self.instance
@instance ||= first
@instance ||= new
end
end
|
Make all the lines that create dice be consistent | require_relative 'hand'
require_relative 'loaded_die'
describe Hand do
it "has five dice, each of which has a known face value" do
dice = 5.times.map { LoadedDie.new('Q') }
hand = Hand.new( dice )
expect( hand.face_values ).to eq( %w[ Q Q Q Q Q ] )
end
specify "a Hand with five Queens is ranked as '... | require_relative 'hand'
require_relative 'loaded_die'
describe Hand do
it "has five dice, each of which has a known face value" do
dice = %w[ Q Q Q Q Q ].map { |value| LoadedDie.new(value) }
hand = Hand.new( dice )
expect( hand.face_values ).to eq( %w[ Q Q Q Q Q ] )
end
specify "a Hand with five Que... |
Update yum dep from 3.0 to 3.2 | name 'yum-erlang_solutions'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@chef.io'
license 'Apache 2.0'
description 'Installs/Configures yum-erlang_solutions'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.1'
depends 'yum', '~> 3.0'
%w(amazon centos fedora oracle ... | name 'yum-erlang_solutions'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@chef.io'
license 'Apache 2.0'
description 'Installs/Configures yum-erlang_solutions'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.1'
depends 'yum', '~> 3.2'
%w(amazon centos fedora oracle ... |
Add unique index for spree option type lower name | class AddUniqueIndexToSpreeOptionTypeName < SpreeExtension::Migration[4.2]
def change
return if check_lower_index_exists?
attributes = Spree::OptionType.unscoped.group(:name).having('sum(1) > 1').pluck(:name)
instances = Spree::OptionType.where(name: [nil, attributes])
instances.find_each do |instan... | |
Fix tests that broke as a result of a merge | require 'spec_helper'
describe FeaturedWorksController do
describe "#create" do
before do
sign_in FactoryGirl.create(:normal_user)
expect(controller).to receive(:authorize!).with(:create, FeaturedWork).and_return(true)
end
context "when there are no featured works" do
it "should create... | require 'spec_helper'
describe FeaturedWorksController do
describe "#create" do
before do
sign_in FactoryGirl.create(:user)
expect(controller).to receive(:authorize!).with(:create, FeaturedWork).and_return(true)
end
context "when there are no featured works" do
it "should create one" d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.