Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Remove no_prisoner_packs method - now obsolete | module SmartAnswer::Calculators
class ArrestedAbroad
# created for the help-if-you-are-arrested-abroad calculator
attr_reader :data
def initialize
@data = self.class.prisoner_packs
end
def no_prisoner_packs
%w()
end
def generate_url_for_download(country, field, text)
u... | module SmartAnswer::Calculators
class ArrestedAbroad
# created for the help-if-you-are-arrested-abroad calculator
attr_reader :data
def initialize
@data = self.class.prisoner_packs
end
def generate_url_for_download(country, field, text)
url = @data.select { |c| c["slug"] == country }... |
Update dev and runtime dependencies | require File.expand_path('../lib/git_handler/version', __FILE__)
Gem::Specification.new do |s|
s.name = "git_handler"
s.version = GitHandler::VERSION
s.summary = "Library to handle git requests over SSH"
s.description = "Library to handle git requests over SSH"
s.homepage = "http://github.c... | require File.expand_path('../lib/git_handler/version', __FILE__)
Gem::Specification.new do |s|
s.name = "git_handler"
s.version = GitHandler::VERSION
s.summary = "Library to handle git requests over SSH"
s.description = "Library to handle git requests over SSH"
s.homepage = "http://github.c... |
Upgrade Adobe AIR to v19.0 | cask :v1 => 'adobe-air' do
version '18.0'
sha256 :no_check # required as upstream package is updated in-place
url "http://airdownload.adobe.com/air/mac/download/#{version}/AdobeAIR.dmg"
name 'Adobe AIR'
homepage 'https://get.adobe.com/air/'
license :gratis
installer :script => 'Adobe AIR Installer.app/C... | cask :v1 => 'adobe-air' do
version '19.0'
sha256 :no_check # required as upstream package is updated in-place
url "http://airdownload.adobe.com/air/mac/download/#{version}/AdobeAIR.dmg"
name 'Adobe AIR'
homepage 'https://get.adobe.com/air/'
license :gratis
installer :script => 'Adobe AIR Installer.app/C... |
Add another case-insensitive unqiue indx, this time to user_name | class UniqueUserNameIndex < ActiveRecord::Migration
def self.up
execute <<-SQL
CREATE UNIQUE INDEX lower_username ON users (LOWER(user_name));
SQL
end
def self.down
execute <<-SQL
DROP INDEX lower_username_ix;
SQL
end
end
| |
Add Pritunl OpenVPN Client cask | cask :v1 => 'pritunl' do
version '0.10.14'
sha256 'afa302d8e95d1635584673a3c206d370c93846f519735d9898e75af43d9bd3a8'
# github.com is the official download host per the vendor homepage
url "https://github.com/pritunl/pritunl-client-electron/releases/download/#{version}/Pritunl.pkg.zip"
appcast 'https://github... | |
Add tests for search controller | require 'rails_helper'
RSpec.describe SearchesController, type: :controller do
include_context 'has all objects'
# Initiate objects
before :each do
user
entry
end
describe 'show' do
it 'should redirect to login url if not logged in' do
get :show
expect(response.status).to eq 302
... | |
Move key to /vagrant and install via remote_file | # Setup the server to allow pull access from git repo
#
REPO='empty-joomla-template'
KEYNAME="#{REPO}_rsa"
GITUSER='vagrant'
SSHDIR="/home/#{GITUSER}/.ssh"
KEYPATH="#{SSHDIR}/new-#{KEYNAME}"
# Setup ssh keys. This scheme will allow us to set GIT_SSH to point to
# a repo-specific script and pull from there.
# Inst... | # Setup the server to allow pull access from git repo
#
REPO='empty-joomla-template'
KEYNAME="#{REPO}_rsa"
GITUSER='vagrant'
SSHDIR="/home/#{GITUSER}/.ssh"
KEYPATH="#{SSHDIR}/new-#{KEYNAME}"
# Setup ssh keys. This scheme will allow us to set GIT_SSH to point to
# a repo-specific script and pull from there.
# Inst... |
Patch for Selenium intermittent errors | # REMOVE THIS FILE WHEN
# http://code.google.com/p/selenium/issues/detail?id=2287
# http://code.google.com/p/selenium/issues/detail?id=2099
# GET FIXED
class Capybara::Selenium::Driver
def find(selector)
begin
browser.find_elements(:xpath, selector).map { |node| Capybara::Selenium::Node.new(self, node) }
... | |
Create if statement that redirects logged in users home if they try to access a profile page that isn't theirs | class UsersController < ApplicationController
def new
@user = User.new
end
def create
user_params
@user = User.new(user_params)
if @user.save
log_in @user
redirect_to @user
else
render 'new'
end
end
def show
find_user
end
def edit
find_user
end
def... | class UsersController < ApplicationController
def new
@user = User.new
end
def create
user_params
@user = User.new(user_params)
if @user.save
log_in @user
redirect_to @user
else
render 'new'
end
end
def show
find_user
if (current_user != @user) || @user.blan... |
Revert "Task should assign target, status and assigned on save, not only on create" | class Comment
def before_save
self.target ||= project
set_status_and_assigned if self.target.is_a?(Task)
end
def after_create
self.target.reload
@activity = project && project.log_activity(self, 'create')
target.after_comment(self) if target.respond_to?(:after_comment)
target... | class Comment
def before_create
self.target ||= project
set_status_and_assigned if self.target.is_a?(Task)
end
def after_create
self.target.reload
@activity = project && project.log_activity(self, 'create')
target.after_comment(self) if target.respond_to?(:after_comment)
targ... |
Add gSOAP formula, version 2.8.6 | require 'formula'
class Gsoap < Formula
url 'http://downloads.sourceforge.net/project/gsoap2/gSOAP/gsoap_2.8.6.zip'
homepage 'http://www.cs.fsu.edu/~engelen/soap.html'
md5 'c0b962c6216bcf59255dc4288783252f'
def install
ENV.deparallelize
system './configure', "--prefix=#{prefix}"
system 'make insta... | |
Fix for dependency installation failure. | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "lumidatum_client"
spec.version = "0.1.0"
spec.authors = ["Mat Lee"]
spec.email = ["matt@lumidatum.com"]
spec.summary ... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = "lumidatum_client"
spec.version = "0.1.2"
spec.authors = ["Mat Lee"]
spec.email = ["matt@lumidatum.com"]
spec.summary ... |
Change from whitelisting to blacklisting interfaces. Exclude only loopback interface by default | require "server_metrics/system_info"
class ServerMetrics::Network < ServerMetrics::MultiCollector
def build_report
if linux?
lines = File.read("/proc/net/dev").lines.to_a[2..-1]
interfaces = []
lines.each do |line|
iface, rest = line.split(':', 2).collect { |e| e.strip }
interf... | require "server_metrics/system_info"
class ServerMetrics::Network < ServerMetrics::MultiCollector
def build_report
if linux?
lines = File.read("/proc/net/dev").lines.to_a[2..-1]
interfaces = []
lines.each do |line|
iface, rest = line.split(':', 2).collect { |e| e.strip }
interf... |
Rename method argument for clarification | module Braingasm
module Options
@options = {}
@defaults = {
eof: 0
}.freeze
def self.[](option)
return @options[option] if @options.has_key?(option)
check_defaults(option)
@defaults[option]
end
def self.[]=(option, value)
check_defaults(option)
@options[op... | module Braingasm
module Options
@options = {}
@defaults = {
eof: 0
}.freeze
def self.[](option)
return @options[option] if @options.has_key?(option)
check_defaults(option)
@defaults[option]
end
def self.[]=(option, value)
check_defaults(option)
@options[op... |
Add RSpec helper with initial configuration for filtering VCR sensitive data, expectation syntax, load paths, etc. | $:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'coveralls'
Coveralls.wear_merged!
require 'rspec'
require 'vcr'
require 'exlibris-nyu'
require 'pry'
# Use the included testmnt for testing.
Exlibris::Aleph.configure do |config|
config.tab_path = "#{File.dirname(... | |
Add new route to access all items | Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
| Rails.application.routes.draw do
get '/items', to: 'items#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
Create a note about strange ruby behaviour | module ShallowAttributes
module Type
# Abstract class for typecast object to Date type.
#
# @abstract
#
# @since 0.1.0
class Date
# Convert value to Date type
#
# @private
#
# @param [Object] value
# @param [Hash] _options
#
# @example Convert st... | module ShallowAttributes
module Type
# Abstract class for typecast object to Date type.
#
# @abstract
#
# @since 0.1.0
class Date
# Convert value to Date type
#
# @private
#
# @param [Object] value
# @param [Hash] _options
#
# @example Convert st... |
Add id & priority to `Annotation` | module Watnow
class Annotation
@@instances = []
attr_accessor :file, :lines
def self.all
@@instances
end
def initialize(opts)
super()
@file = opts[:file]
@lines = set_lines(opts[:lines])
@@instances << self
end
private
def set_lines(lines)
res... | module Watnow
class Annotation
@@id = 0
@@instances = []
attr_accessor :id, :file, :lines, :priority
def self.all
@@instances
end
def initialize(opts)
super()
@priority = 0
@file = opts[:file]
@lines = set_lines(opts[:lines])
@id = @@id += 1
@@ins... |
Revert "10 minutes => 60minutes" | env :MAILTO, '""'
env :PATH, ENV['PATH']
set :output, 'log/cron_log.log'
job_type :envcommand, '. ~/.profile; cd :path && RAILS_ENV=:environment :task'
# on some systems, need to source rvm before running standard rake command
job_type :rake, '. ~/.profile; cd :path && RAILS_ENV=:environment bundle exec rake :task ... | env :MAILTO, '""'
env :PATH, ENV['PATH']
set :output, 'log/cron_log.log'
job_type :envcommand, '. ~/.profile; cd :path && RAILS_ENV=:environment :task'
# on some systems, need to source rvm before running standard rake command
job_type :rake, '. ~/.profile; cd :path && RAILS_ENV=:environment bundle exec rake :task ... |
Allow user email on sessions. | class SessionsController < ApplicationController
include Api
def create
session = Session.new(session_params)
session.app = @app
session.save
render_api_create_response session
end
private
def session_params
params.require(:session).permit(:user_id, :user_name, :browser)
end
end
| class SessionsController < ApplicationController
include Api
def create
session = Session.new(session_params)
session.app = @app
session.save
render_api_create_response session
end
private
def session_params
params.require(:session).permit(:user_id, :user_name, :email, :browser)
end
end... |
Add encryptable to old migration | class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token... | class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
t.encryptable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :r... |
Use Sets, because we can. | module GitCleanser
class SmartThing
def initialize(config)
@config = config
@compiled_files = sh(@config['compiled_files_command']).split
@ignored_and_untracked_files = git_ls_files(:ignored, :other)
@ignored_but_tracked_files = git_ls_files(:ignored)
@all_files = Dir['**/*']
end... | require 'set'
module GitCleanser
class SmartThing
def initialize(config)
@config = config
@compiled_files = sh(@config['compiled_files_command']).split.to_set
@ignored_and_untracked_files = git_ls_files(:ignored, :other)
@ignored_but_tracked_files = git_ls_files(:ignored)
@all_files... |
Add home route for voting namespace | Rails.application.routes.draw do
namespace 'admin' do
resources :proposals
root 'proposals#index'
end
namespace 'voting' do
resources :proposals, only: [:index, :show, :update] do
collection do
get 'summarize'
end
end
end
namespace 'monitoring' do
resources :proposal... | Rails.application.routes.draw do
namespace 'admin' do
resources :proposals
root 'proposals#index'
end
namespace 'voting' do
resources :proposals, only: [:index, :show, :update] do
collection do
get 'summarize'
end
end
root 'proposals#index'
end
namespace 'monitoring... |
Add notification when file is opened. | if defined?(Konacha)
require 'rspec'
require 'ci/reporter/rake/rspec_loader'
require 'yarjuf'
Konacha.configure do |config|
config.spec_dir = "spec/javascripts"
config.spec_matcher = /_spec\./
config.driver = :poltergeist
config.stylesheets = []
if ENV['JENKINS_URL']
config.... | if defined?(Konacha)
require 'rspec'
require 'ci/reporter/rake/rspec_loader'
require 'yarjuf'
Konacha.configure do |config|
config.spec_dir = "spec/javascripts"
config.spec_matcher = /_spec\./
config.driver = :poltergeist
config.stylesheets = []
if ENV['JENKINS_URL']
puts "!... |
Add spec for including only *.css files | require 'cc/engine/csslint'
require 'tmpdir'
module CC
module Engine
describe CSSlint do
let(:code) { Dir.mktmpdir }
let(:lint) { CSSlint.new(directory: code, io: nil, engine_config: {}) }
let(:content) { '#id { color: red; }' }
describe '#run' do
it 'analyzes *.css files' do
... | |
Test connection closing in an SSL compliant way | require_relative './connection_spec_init'
context 'Connection' do
test 'Closing' do
socket = StringIO.new
io = StringIO.new
connection = Connection.new socket, io, 0
connection.close
assert connection.closed?
assert socket.closed?
assert io.closed?
end
end
| |
Clean up return statement for readability | class Organization < ActiveRecord::Base
has_many :organization_users
has_many :users, through: :organization_users
has_many :orders
has_many :addresses
accepts_nested_attributes_for :addresses, allow_destroy: true
validates :name, uniqueness: true
before_save :add_county
def add_county
return unle... | class Organization < ActiveRecord::Base
has_many :organization_users
has_many :users, through: :organization_users
has_many :orders
has_many :addresses
accepts_nested_attributes_for :addresses, allow_destroy: true
validates :name, uniqueness: true
before_save :add_county
def add_county
return if c... |
Use mattr_accessor and make 5 seconds as constant | require 'httparty'
require 'nokogiri'
require 'ares/version'
require 'ares/errors'
require 'ares/logging'
require 'ares/client'
require 'ico-validator'
module Ares
cattr_accessor :timeout do
5
end
class << self
include Ares::Logging
# Returns standard client
# @returns [Client::Standard]
de... | require 'httparty'
require 'nokogiri'
require 'ares/version'
require 'ares/errors'
require 'ares/logging'
require 'ares/client'
require 'ico-validator'
module Ares
DEFAULT_TIMEOUT = 5
@@timeout = DEFAULT_TIMEOUT
mattr_accessor :timeout
class << self
include Ares::Logging
# Returns standard client
... |
Call JIRA and fetch issue details | require 'slack-ruby-bot'
class JiraBot < SlackRubyBot::Bot
match(/([a-z]+-[0-9]+)/i) do |client, data, issues|
results = []
tomatch = data.text
# Remove links from text, since they're already links, by grabbing everything between < and >
tomatch = tomatch.sub /(<.+>)/i, ''
# Also remove emo... | require 'slack-ruby-bot'
require "net/https"
require "uri"
require "JSON"
class JiraBot < SlackRubyBot::Bot
match(/([a-z]+-[0-9]+)/i) do |client, data, issues|
results = []
tomatch = data.text
# Remove links from text, since they're already links, by grabbing everything between < and >
tomatch =... |
Add capistrano and capistrano_colors as dependencies. | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/capistrano/fanfare/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Fletcher Nichol"]
gem.email = ["fnichol@nichol.ca"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summ... | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/capistrano/fanfare/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Fletcher Nichol"]
gem.email = ["fnichol@nichol.ca"]
gem.description = %q{TODO: Write a gem description}
gem.summary = %q{TODO: Write a gem summ... |
Add locale support to URLs | require "spec_helper"
describe ApplicationController do
let(:instance) { ApplicationController.new }
describe "#default_url_options" do
let(:locale) { :pirate }
before { I18n.stub(:locale) { locale } }
it "sets the locale" do
instance.default_url_options[:locale].should eq(locale)
end
end... | |
Set minimum iOS version on `platform` in the podspec file | Pod::Spec.new do |spec|
spec.name = 'KeenClientTD'
spec.version = '3.2.28'
spec.license = { :type => 'MIT' }
spec.platforms = { :ios => "", :tvos => "" }
spec.homepage = 'https://github.com/treasure-data/KeenClient-iOS'
spec.authors = { 'Mitsunori Komatsu' => 'mitsu@treasure-da... | Pod::Spec.new do |spec|
spec.name = 'KeenClientTD'
spec.version = '3.2.28'
spec.license = { :type => 'MIT' }
spec.platforms = { :ios => "5.0", :tvos => "5.0" }
spec.homepage = 'https://github.com/treasure-data/KeenClient-iOS'
spec.authors = { 'Mitsunori Komatsu' => 'mitsu@treas... |
Add gem dependency at the top | require_relative "gothonweb/version"
require_relative "map"
require "sinatra"
require "erb"
module Gothonweb
use Rack::Session::Pool
get '/' do
# this is used to "setup" the session with starting values
p START
session[:room] = START
redirect("/game")
end
get '/game' do
if session[:room]... | gem 'sinatra', '1.3.6'
require_relative "gothonweb/version"
require_relative "map"
require "sinatra"
require "erb"
module Gothonweb
use Rack::Session::Pool
get '/' do
# this is used to "setup" the session with starting values
p START
session[:room] = START
redirect("/game")
end
get '/game' ... |
Remove Miss and add Dr to honorifics | class User < ApplicationRecord
HONORIFICS = %w(
Miss
Mr.
Mrs.
Ms.
).freeze
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, # :registerable,
:recoverable, :rememberable, :trackable, :va... | class User < ApplicationRecord
HONORIFICS = %w(
Mr.
Ms.
Mrs.
Dr.
).freeze
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, # :registerable,
:recoverable, :rememberable, :trackable, :val... |
Set ADA colour theme correctly. | Themenap::Config.active = ! ADAPT::CONFIG['adapt.theme.old']
Themenap::Config.server = 'http://178.79.149.181'
Themenap::Config.snippets =
[ { :css => 'title',
:text => '<%= yield :title %>' },
{ :css => 'head',
:text => '<%= render "layouts/css_includes" %>',
:mode => :append },
{ :css => '... | Themenap::Config.active = ! ADAPT::CONFIG['adapt.theme.old']
Themenap::Config.server = 'http://178.79.149.181'
Themenap::Config.snippets =
[ { :css => 'title',
:text => '<%= yield :title %>' },
{ :css => 'head',
:text => '<%= render "layouts/css_includes" %>',
:mode => :append },
{ :css => '... |
Allow patch for updating products | module SolidusMailchimpSync
class ProductSynchronizer < BaseSynchronizer
self.serializer_class_name = "::SolidusMailchimpSync::ProductSerializer"
self.synced_attributes = %w{name description slug available_on}
# Since Mailchimp API 3.0 doesn't let us update products, important to wait
# until product... | module SolidusMailchimpSync
class ProductSynchronizer < BaseSynchronizer
self.serializer_class_name = "::SolidusMailchimpSync::ProductSerializer"
self.synced_attributes = %w{name description slug available_on}
# Since Mailchimp API 3.0 doesn't let us update products, important to wait
# until product... |
Replace data clump with class (in EditCommand) | require 'spec_helper'
require 'markdo/commands/inbox_command'
module Markdo
describe EditCommand do
it 'edits the Markdo root in your preferred editor' do
skip 'Shellwords not supported' unless defined?(Shellwords)
out, err = build_command_support
env = { 'EDITOR' => 'aneditor', 'MARKDO_ROOT' ... | require 'spec_helper'
require 'markdo/commands/inbox_command'
module Markdo
describe EditCommand do
it 'edits the Markdo root in your preferred editor' do
skip 'Shellwords not supported' unless defined?(Shellwords)
command_support = build_command_support_object({
'EDITOR' => 'aneditor',
... |
Set default environment vars to run recorded tests without config | shared_context "integration" do
let :api do
Bigcommerce::Api.new({
store_url: ENV['API_URL'],
username: ENV['API_USER'],
api_key: ENV['API_PASS']
})
end
end | shared_context "integration" do
let :api do
ENV['API_URL'] = ENV['API_URL'] || 'https://store-vnh06c71.mybigcommerce.com'
ENV['API_USER'] = ENV['API_USER'] || 'apiuser'
ENV['API_PASS'] = ENV['API_PASS'] || '123456'
Bigcommerce::Api.new({
:store_url => ENV['API_URL'],
:username => ENV[... |
Set a sensible limit to the allowed_children_cache column (esp important for DB/2). Fixes GH-309. | class AddAllowedChildrenCacheToPages < ActiveRecord::Migration
def self.up
add_column :pages, :allowed_children_cache, :string, :default => ''
Page.reset_column_information
Page.find_each do |page|
page.save # update the allowed_children_cache
end
end
def self.down
remove_column :pages,... | class AddAllowedChildrenCacheToPages < ActiveRecord::Migration
def self.up
add_column :pages, :allowed_children_cache, :string, :limit => 1500, :default => ''
Page.reset_column_information
Page.find_each do |page|
page.save # update the allowed_children_cache
end
end
def self.down
remov... |
Add dependency 'thor', 'milkode', 'github_api' | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mygithub/version'
Gem::Specification.new do |gem|
gem.name = "mygithub"
gem.version = Mygithub::VERSION
gem.authors = ["ongaeshi"]
gem.email = ["ong... | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mygithub/version'
Gem::Specification.new do |gem|
gem.name = "mygithub"
gem.version = Mygithub::VERSION
gem.authors = ["ongaeshi"]
gem.email = ["ong... |
Drop TLS support for now | class Fluentd
module Setting
class InForward
include Fluentd::Setting::Plugin
register_plugin("input", "forward")
def self.initial_params
{
bind: "0.0.0.0",
port: 24224,
linger_timeout: 0,
chunk_size_limit: nil,
chunk_size_warn_limit: n... | class Fluentd
module Setting
class InForward
include Fluentd::Setting::Plugin
register_plugin("input", "forward")
def self.initial_params
{
bind: "0.0.0.0",
port: 24224,
linger_timeout: 0,
chunk_size_limit: nil,
chunk_size_warn_limit: n... |
Change of show-config recipe to point at new chef-server.rb | #
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
#
# All Rights Reserved
#
if File.exists?("/etc/opscode/private-chef.rb")
PrivateChef[:node] = node
PrivateChef.from_file("/etc/opscode/private-chef.rb")
end
config = PrivateChef.generate_config(node['fqdn'])
puts Chef::JSON... | #
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2012 Opscode, Inc.
#
# All Rights Reserved
#
if File.exists?("/etc/opscode/chef-server.rb")
PrivateChef[:node] = node
PrivateChef.from_file("/etc/opscode/chef-server.rb")
end
config = PrivateChef.generate_config(node['fqdn'])
puts Chef::JSONCo... |
Fix flash message in users controller, it should be fetched in block, otherwise message is fetched while loading controller, before any locales are loaded. | class UsersController < Spree::BaseController
resource_controller
ssl_required :new, :create, :edit, :update, :show
actions :all, :except => [:index, :destroy]
show.before do
@orders = @user.orders.complete
end
create.after do
associate_user
end
create.flash nil
create.wants.html { redire... | class UsersController < Spree::BaseController
resource_controller
ssl_required :new, :create, :edit, :update, :show
actions :all, :except => [:index, :destroy]
show.before do
@orders = @user.orders.complete
end
create.after do
associate_user
end
create.flash nil
create.wants.html { redire... |
Make comments unnecessary by making Tokenizer's API more expressive | require 'forwardable'
class Calculator
def add(*numbers)
numbers.flatten.inject(0, &:+)
end
def subtract(*numbers)
numbers.inject(numbers.shift, &:-)
end
def multiply(*numbers)
numbers.inject(1, &:*)
end
def divide(*numbers)
numbers.inject(numbers.shift, &:/)
end
def evaluate(expre... | require 'forwardable'
class Calculator
def add(*numbers)
numbers.flatten.inject(0, &:+)
end
def subtract(*numbers)
numbers.inject(numbers.shift, &:-)
end
def multiply(*numbers)
numbers.inject(1, &:*)
end
def divide(*numbers)
numbers.inject(numbers.shift, &:/)
end
def evaluate(expre... |
Add class for casting a format to string | # frozen_string_literal: true
module RubyRabbitmqJanus
# Format data with type corresponding
class TypeData
def initialize(type, value)
@type = type
@value = value
end
# Cast a string
def format
case @type
when '<number>'
@value.to_i
when '<string>'
@v... | |
Convert log message to format; fails on array, int, etc. | def log(msg, level = :info)
if Sidekiq::Logging.logger
Sidekiq::Logging.logger.send level, msg
elsif Rails.logger
Rails.logger.send level, msg
else
puts msg
end
end
| def log(msg, level = :info)
msg = msg.to_s
if Sidekiq::Logging.logger
Sidekiq::Logging.logger.send level, msg
elsif Rails.logger
Rails.logger.send level, msg
else
puts msg
end
end
|
Add tests for browse controller | require_relative "../test_helper"
class BrowseControllerTest < ActionController::TestCase
context "GET index" do
should "list all categories" do
content_api_has_root_sections(["crime-and-justice"])
get :index
url = "http://www.test.gov.uk/browse/crime-and-justice"
assert_select "ul h2 a",... | |
Add final changes to factorial solution | # Factorial
# I worked on this challenge Bryan Munroe.
# Your Solution Below
def factorial(number)
n = 0
x = 1
if number == 0
return 1
else
while number > n
x = x * number
number -= 1
end
end
return x
end | # Factorial
# I worked on this challenge Bryan Munroe.
# Your Solution Below
def factorial(number)
n = 0
x = 1
if number == 0
return 1
else
while number > 0
x = x * number
number -= 1
end
end
return x
end |
Declare id3tag gem as runtime dependency | require File.expand_path('../lib/scube/cli/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'scube-cli'
s.version = Scube::CLI::VERSION.dup
s.summary = 'CLI client for Scube'
s.description = s.name
s.license = 'BSD-3-Clause'
s.homepage = 'https://rubygems.org/gems/scube-cli'... | require File.expand_path('../lib/scube/cli/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'scube-cli'
s.version = Scube::CLI::VERSION.dup
s.summary = 'CLI client for Scube'
s.description = s.name
s.license = 'BSD-3-Clause'
s.homepage = 'https://rubygems.org/gems/scube-cli'... |
Add LICENSE and documenation files to the gem RDoc; Bump version to 1.1.6 | spec = Gem::Specification.new do |s|
s.name = "scaffolding_extensions"
s.version = '1.1.5'
s.author = "Jeremy Evans"
s.email = "code@jeremyevans.net"
s.platform = Gem::Platform::RUBY
s.summary = "Administrative database front-end for multiple web-frameworks and ORMs"
s.files = %w'LICENSE README' + Dir['{l... | spec = Gem::Specification.new do |s|
s.name = "scaffolding_extensions"
s.version = '1.1.6'
s.author = "Jeremy Evans"
s.email = "code@jeremyevans.net"
s.platform = Gem::Platform::RUBY
s.summary = "Administrative database front-end for multiple web-frameworks and ORMs"
s.files = %w'LICENSE README' + Dir['{l... |
Add plausible? to performance script. | # Rubinius profiling.
# Run with:
# ruby -Xprofiler.full_report -Xprofiler.graph performance/rubinius.rb
require 'rubinius/profiler'
require_relative '../lib/phony'
def profile
profiler = Rubinius::Profiler::Instrumenter.new
profiler.start
yield
profiler.stop
profiler.show # takes on IO object, defau... | # Rubinius profiling.
# Run with:
# ruby -Xprofiler.full_report -Xprofiler.graph performance/rubinius.rb
require 'rubinius/profiler'
require_relative '../lib/phony'
def profile
profiler = Rubinius::Profiler::Instrumenter.new
profiler.start
yield
profiler.stop
profiler.show # takes on IO object, defau... |
Fix falsy test in pip requirements hook | DEBUG = false
# Get the commits before the merge
# ex. heads = ["<latest commit of master>", "<previous commit of master>", ...]
heads = `git reflog -n 2 | awk '{ print $1 }'`.split
# Make sure our revision history has at least 2 entries
if heads.length < 2
exit 0
end
files = `git diff --name-only #{heads[1]}... | # Get the commits before the merge
# ex. heads = ["<latest commit of master>", "<previous commit of master>", ...]
heads = `git reflog -n 2 | awk '{ print $1 }'`.split
# Make sure our revision history has at least 2 entries
if heads.length < 2
exit 0
end
# Get all files that changed
files = `git diff --name-onl... |
Fix Redirects And Names In Controller | class QuestionsController < ApplicationController
before_action :set_question, only: [:show, :edit, :update, :destroy]
def index
@questions = Question.all
end
def show
end
def new
@question = Question.new
end
def create
@question = Question.new(question_params)
if @question.save
... | class QuestionsController < ApplicationController
before_action :set_question, only: [:show, :edit, :update, :destroy]
def index
@questions = Question.all
end
def show
end
def new
@question = Question.new
end
def create
@question = Question.new(question_params)
if @question.save
... |
Handle when asset compilation is off in rails. | module HandlebarsAssets
# NOTE: must be an engine because we are including assets in the gem
class Engine < ::Rails::Engine
initializer "handlebars_assets.assets.register", :group => :all do |app|
::HandlebarsAssets::register_extensions(app.assets)
if Gem::Version.new(Sprockets::VERSION) < Gem::Vers... | module HandlebarsAssets
# NOTE: must be an engine because we are including assets in the gem
class Engine < ::Rails::Engine
initializer "handlebars_assets.assets.register", :group => :all do |app|
sprockets_env = app.assets || Sprockets
::HandlebarsAssets::register_extensions(sprockets_env)
if... |
Read messages from MBox by offset | module Imap::Backup
class Serializer::Mbox
attr_reader :folder_path
def initialize(folder_path)
@folder_path = folder_path
end
def valid?
exist?
end
def append(message)
File.open(pathname, "ab") do |file|
file.write message
end
end
def delete
r... | module Imap::Backup
class Serializer::Mbox
attr_reader :folder_path
def initialize(folder_path)
@folder_path = folder_path
end
def valid?
exist?
end
def append(message)
File.open(pathname, "ab") do |file|
file.write message
end
end
def read(offset, l... |
Fix gem breaking when multisite config is not present. | # frozen_string_literal: true
module RailsMultisite
class Railtie < Rails::Railtie
rake_tasks do
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
end
initializer "RailsMultisite.init" do |app|
Rails.configuration.multisite = false
config_file = ConnectionM... | # frozen_string_literal: true
module RailsMultisite
class Railtie < Rails::Railtie
rake_tasks do
Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
end
initializer "RailsMultisite.init" do |app|
Rails.configuration.multisite = false
config_file = ConnectionM... |
Add some default classes to the table | require 'rack/utils'
require 'cgi'
module Sequel::Reporter
module Helpers
include Rack::Utils
def partial(template, locals = {})
render_engine = locals.delete(:render_engine) || settings.render_engine
render render_engine, template, :layout => false, :locals => locals
end
def table(rep... | require 'rack/utils'
require 'cgi'
module Sequel::Reporter
module Helpers
include Rack::Utils
def partial(template, locals = {})
render_engine = locals.delete(:render_engine) || settings.render_engine
render render_engine, template, :layout => false, :locals => locals
end
def table(rep... |
Fix typo in FrameOptions example description | require File.expand_path('../spec_helper.rb', __FILE__)
describe Rack::Protection::FrameOptions do
it_behaves_like "any rack application"
it 'should set the X-XSS-Protection' do
get('/').headers["X-Frame-Options"].should == "sameorigin"
end
it 'should allow changing the protection mode' do
# I have n... | require File.expand_path('../spec_helper.rb', __FILE__)
describe Rack::Protection::FrameOptions do
it_behaves_like "any rack application"
it 'should set the X-Frame-Options' do
get('/').headers["X-Frame-Options"].should == "sameorigin"
end
it 'should allow changing the protection mode' do
# I have no... |
Store uri rather than id for config blobs. | module Cradlepointr
class Router < CradlepointObject
attr_accessor :id, :data, :ecm_firmware_id
def initialize(id = nil)
self.id = id
end
def self.rel_url
'/routers'
end
def rel_url
Cradlepointr::Router.rel_url
end
def self.rel_url_with_id(id)
"#{ rel_url }... | module Cradlepointr
class Router < CradlepointObject
attr_accessor :id, :data, :ecm_firmware_uri, :ecm_configuration_uri
def initialize(id = nil)
self.id = id
end
def self.rel_url
'/routers'
end
def rel_url
Cradlepointr::Router.rel_url
end
def self.rel_url_with_i... |
Use parse_domain methods to obtain domains variable | begin
Capistrano::Configuration.instance.load do
namespace :nginx do
desc "Install latest stable release of nginx"
task :install, roles: :web do
run "#{sudo} add-apt-repository -y ppa:nginx/stable"
run "#{sudo} apt-get -y update"
run "#{sudo} apt-get -y install nginx"
en... | begin
Capistrano::Configuration.instance.load do
namespace :nginx do
desc "Install latest stable release of nginx"
task :install, roles: :web do
run "#{sudo} add-apt-repository -y ppa:nginx/stable"
run "#{sudo} apt-get -y update"
run "#{sudo} apt-get -y install nginx"
en... |
Rollback to CarrierWave 0.5.8 problem. | require 'active_support/concern'
require 'carrierwave/mongoid'
require 'media_magick/attachment_uploader'
require 'mongoid'
module CarrierWave
module Uploader
module Url
extend ActiveSupport::Concern
include CarrierWave::Uploader::Configuration
##
# === Returns
#
# [String] t... | require 'active_support/concern'
require 'carrierwave/mongoid'
require 'media_magick/attachment_uploader'
require 'mongoid'
module MediaMagick
module Model
extend ActiveSupport::Concern
module ClassMethods
def attachs_many(name, options = {}, &block)
klass = Class.new do
include ... |
Make send testscript more relevant. | #!/usr/bin/env ruby
require 'json'
require 'bunny'
conn = Bunny.new 'amqp://guest:guest@172.23.25.65:5672'
conn.start
ch = conn.create_channel
tqone = ch.queue(ARGV.first)
x = ch.default_exchange
msg = {
handler: 'chef',
run_list: 'recipe[chef-metal::nextranet]',
override_attributes: ... | #!/usr/bin/env ruby
require 'json'
require 'bunny'
conn = Bunny.new 'amqp://orc-agent:ownme@mq.your.com:5672'
conn.start
ch = conn.create_channel
q = ch.queue(ARGV.first)
x = ch.default_exchange
msg = {
handler: 'chef',
run_list: 'recipe[your_webapp:redeploy]',
override_attributes: { ... |
Fix for Spree 4.1+ plus this should be only available for paid orders | Deface::Override.new(
virtual_path: 'spree/shared/_order_details',
name: 'add_digital_downloads_to_invoice',
insert_bottom: 'td[data-hook="order_item_description"]',
text: <<-HTML
<% if @order.state == 'complete' and item.variant.digital? %>
<div data-hook='download_links'>
<... | Deface::Override.new(
virtual_path: 'spree/shared/_order_details',
name: 'add_digital_downloads_to_invoice',
insert_bottom: '[data-hook="order_item_description"]',
text: <<-HTML
<% if @order.state == 'complete' && @order.paid? && item.variant.digital? %>
<div data-hook='download_links'>
... |
Add cask for Chromatic version 0.2.3 | class Chromatic < Cask
url 'http://download.mrgeckosmedia.com/Chromatic.zip'
homepage 'https://mrgeckosmedia.com/applications/info/Chromatic'
version '0.2.3'
sha1 '5b28e43f89480d339a5f323c2650a2d4a2b5d487'
link 'Chromatic.app'
end
| |
Fix customer_id in payload for loggin | # Copyright © Mapotempo, 2013-2014
#
# This file is part of Mapotempo.
#
# Mapotempo is free software. You can redistribute it and/or
# modify since you respect the terms of the GNU Affero General
# Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any l... | # Copyright © Mapotempo, 2013-2014
#
# This file is part of Mapotempo.
#
# Mapotempo is free software. You can redistribute it and/or
# modify since you respect the terms of the GNU Affero General
# Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any l... |
Fix flash message for invalid credentials. | class SessionsController < ApplicationController
skip_before_filter :require_provider_authentication
def new
end
def create
if current_provider.valid_credentials?(params)
session[:current_provider_creds] = params
return_to = session.delete(:return_to) || root_url
redirect_to return_to, n... | class SessionsController < ApplicationController
skip_before_filter :require_provider_authentication
def new
end
def create
if current_provider.valid_credentials?(params)
session[:current_provider_creds] = params
return_to = session.delete(:return_to) || root_url
redirect_to return_to, n... |
Add spec to reproduce FilterPraser.parse fails with multibyte char | # encoding: utf-8
require 'spec_helper'
describe Net::LDAP::Filter::FilterParser do
describe "#parse" do
context "Given ASCIIs as filter string" do
let(:filter_string) { "(&(objectCategory=person)(objectClass=user))" }
specify "should generate filter object" do
expect(Net::LDAP::Filter::Filt... | |
Allow for versioned asset paths to get automatic cache busting of assets using a CDN that ignores querystrings | # A monkey-patch to AssetTagHelper that prepends a directory with the rails asset it
# to asset paths as well as using an asset query string. CDNs may ignore the querystring
# so this is belt-and-braces cache busting. Requires a webserver-level rewrite rule
# to strip the /rel-[asset-id]/ directory
module ActionView
... | |
Handle different names for nodejs executable | require 'es6-module-mapper/js_runner'
require 'yajl'
module ES6ModuleMapper
class Transformer
VERSION = '1'
TRANSFORMER_CMD = 'node '+ File.join(File.dirname(__FILE__), 'transformer.js')
MODULES_GLOBAL_VAR_NAME = 'window.____modules____'
MODULES_LOCAL_VAR_NAME = '__m__'
def self.call(input)
... | require 'es6-module-mapper/js_runner'
require 'yajl'
module ES6ModuleMapper
class Transformer
VERSION = '1'
NODEJS_CMD = %w[node nodejs].map { |cmd| %x{which #{cmd}}.chomp }.find { |cmd| !cmd.empty? }
TRANSFORMER_CMD = "#{NODEJS_CMD} #{File.join(File.dirname(__FILE__), 'transformer.js')}"
MODULES_GL... |
Use wordsmith.org since dictionary.com no longer has RSS feed | require 'net/http'
require 'uri'
require 'rexml/document'
module Lita
module Handlers
class Wotd < Handler
route(/wotd/, :wotd, command: true, help: {
'wotd' => 'returns the word of the day from dictionary.com'
})
def wotd(response)
response.reply(the_word)
end
pri... | require 'net/http'
require 'uri'
require 'rexml/document'
module Lita
module Handlers
class Wotd < Handler
WOTD_URL = 'https://wordsmith.org/awad/rss1.xml'.freeze
route(/wotd/, :wotd, command: true, help: {
'wotd' => 'returns the word of the day from dictionary.com'
})
def wotd(... |
Update the gemspec with the correct readme | Gem::Specification.new do |s|
s.name = "toadhopper-sinatra"
s.version = "0.3"
s.extra_rdoc_files = ["Readme.md"]
s.summary = "Post Hoptoad notifications from Sinatra"
s.description = s.summary
s.authors = ["Tim Lucas"]
s.email = "t.lucas@toolma... | Gem::Specification.new do |s|
s.name = "toadhopper-sinatra"
s.version = "0.3"
s.extra_rdoc_files = ["Readme.md"]
s.summary = "Post Hoptoad notifications from Sinatra"
s.description = s.summary
s.authors = ["Tim Lucas"]
s.email = "t.lucas@toolma... |
Update help response to include source of results | require 'genius'
module Cinch
module Plugins
class Lyric
include Cinch::Plugin
match /(lyric) (.+)/
match /(genius) (.+)/
match /(help lyric)$/, method: :help
match /(help genius)$/, method: :help
def execute(m, prefix, lyric, keywords)
Genius.access_token = "#{ENV['... | require 'genius'
module Cinch
module Plugins
class Lyric
include Cinch::Plugin
match /(lyric) (.+)/
match /(genius) (.+)/
match /(help lyric)$/, method: :help
match /(help genius)$/, method: :help
def execute(m, prefix, lyric, keywords)
Genius.access_token = "#{ENV['... |
Return empty hash when no config for environment | module SidekiqConfig
def self.namespace
"panoptes_sidekiq_#{ Rails.env }"
end
def self.default_redis
{
host: 'localhost',
port: 6378,
db: 0
}
end
def self.redis_url
config = begin
YAML.load(File.read(Rails.root.join('config/redis.yml')))
rescue Errn... | module SidekiqConfig
def self.namespace
"panoptes_sidekiq_#{ Rails.env }"
end
def self.default_redis
{
host: 'localhost',
port: 6378,
db: 0
}
end
def self.redis_url
config = begin
YAML.load(File.read(Rails.root.join('config/redis.yml')))
config[Ra... |
Update Oxygen icons to 4.5.2. | require 'formula'
class OxygenIcons <Formula
url 'ftp://ftp.kde.org/pub/kde/stable/4.4.2/src/oxygen-icons-4.4.2.tar.bz2'
homepage 'http://www.oxygen-icons.org/'
md5 '86e655d909f743cea6a2fc6dd90f0e52'
depends_on 'cmake' => :build
def install
system "cmake . #{std_cmake_parameters}"
system "make inst... | require 'formula'
class OxygenIcons <Formula
url 'ftp://ftp.kde.org/pub/kde/stable/4.5.2/src/oxygen-icons-4.5.2.tar.bz2'
homepage 'http://www.oxygen-icons.org/'
md5 '64cd34251378251d56b9e56a9d4d7bf6'
depends_on 'cmake' => :build
def install
system "cmake . #{std_cmake_parameters}"
system "make inst... |
Make db/ directory when it doesn't exist already before Groonga db creating | require "grn_mini"
require "sinatra/base"
require "sinatra/reloader"
require "haml"
require "sass"
require "coffee-script"
class MTask < Sinatra::Base
register Sinatra::Reloader
enable :method_override
configure do
GrnMini::create_or_open("db/tasks.db")
$tasks = GrnMini::Array.new("Tasks")
$tasks.... | require "grn_mini"
require "sinatra/base"
require "sinatra/reloader"
require "haml"
require "sass"
require "coffee-script"
class MTask < Sinatra::Base
register Sinatra::Reloader
enable :method_override
configure do
FileUtils.mkdir_p("./db")
GrnMini::create_or_open("db/tasks.db")
$tasks = GrnMini::A... |
Refactor Manual fetching to before_filter | class ManualsController < ApplicationController
def index
manual = ManualsRepository.new.fetch(params["manual_id"])
error_not_found unless manual
@manual = ManualPresenter.new(manual)
end
def show
manual = ManualsRepository.new.fetch(params["manual_id"])
document = ManualsRepository.new.fe... | class ManualsController < ApplicationController
before_filter :set_manual
def index; end
def show
document = ManualsRepository.new.fetch(params["manual_id"], params["section_id"])
error_not_found unless document
@document = DocumentPresenter.new(document, @manual)
end
private
def error_not_... |
Fix quote controller test for mass-assignment protection | require 'test_helper'
class QuotesControllerTest < ActionController::TestCase
setup do
@quote = quotes(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:quotes)
end
test "should get new" do
get :new
assert_response :success
end
tes... | require 'test_helper'
class QuotesControllerTest < ActionController::TestCase
setup do
@quote = quotes(:one)
@quote_attributes = @quote.attributes.slice(:raw_quote, :description)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:quotes)
end
test ... |
Fix country_select unit test to work with updated to_response | require_relative "../test_helper"
module SmartAnswer
class CountrySelectQuestionTest < ActiveSupport::TestCase
def setup
@question = Question::CountrySelect.new(:example)
end
test "Can list options" do
assert @question.options.include?({slug: "azerbaijan", name: "Azerbaijan"})
assert @... | require_relative "../test_helper"
module SmartAnswer
class CountrySelectQuestionTest < ActiveSupport::TestCase
def setup
@question = Question::CountrySelect.new(:example)
end
test "Can list options" do
assert @question.options.include?({slug: "azerbaijan", name: "Azerbaijan"})
assert @... |
Change created_at and updated_at to datetime type | class AddEpixUserFieldsToAnnualReportUpload < ActiveRecord::Migration
def change
add_column :trade_annual_report_uploads, :epix_created_by_id, :integer
add_column :trade_annual_report_uploads, :epix_created_at, :integer
add_column :trade_annual_report_uploads, :epix_updated_by_id, :integer
add_column ... | class AddEpixUserFieldsToAnnualReportUpload < ActiveRecord::Migration
def change
add_column :trade_annual_report_uploads, :epix_created_by_id, :integer
add_column :trade_annual_report_uploads, :epix_created_at, :datetime
add_column :trade_annual_report_uploads, :epix_updated_by_id, :integer
add_column... |
Check environment to exclude PDF generation test. | require 'test_helper'
class Cf0925Test < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test 'generation of a PDF' do
rtp = cf0925s(:one)
assert rtp.generate_pdf
assert File.exist?(rtp.pdf_file), "File #{rtp.pdf_file} not found"
end
end
| require 'test_helper'
class Cf0925Test < ActiveSupport::TestCase
test 'generation of a PDF' do
unless ENV['TEST_PDF_GENERATION']
skip 'Skipping PDF generation. To include: `export TEST_PDF_GENERATION=1`'
end
rtp = cf0925s(:one)
assert rtp.generate_pdf
assert File.exist?(rtp.pdf_file), "File... |
Set correct host for get service operation | module Fog
module AWS
class Storage
class Real
require 'fog/aws/parsers/storage/get_service'
# List information about S3 buckets for authorized user
#
# @return [Excon::Response] response:
# * body [Hash]:
# * Buckets [Hash]:
# * Name [Str... | module Fog
module AWS
class Storage
class Real
require 'fog/aws/parsers/storage/get_service'
# List information about S3 buckets for authorized user
#
# @return [Excon::Response] response:
# * body [Hash]:
# * Buckets [Hash]:
# * Name [Str... |
Update endpoints used by WP OAuth Server 3.1.3 | require 'omniauth-oauth2'
module OmniAuth
module Strategies
class WordpressHosted < OmniAuth::Strategies::OAuth2
# Give your strategy a name.
option :name, 'wordpress_hosted'
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
o... | require 'omniauth-oauth2'
module OmniAuth
module Strategies
class WordpressHosted < OmniAuth::Strategies::OAuth2
# Give your strategy a name.
option :name, 'wordpress_hosted'
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
o... |
Use current environment not production | Capistrano::Configuration.instance(:must_exist).load do
after 'deploy', 'deploy:notify_hoptoad'
after 'deploy:migrations', 'deploy:notify_hoptoad'
namespace :deploy do
desc 'Notify Hoptoad of the deployment'
task :notify_hoptoad, :only => {:primary => true}, :except => {:no_release => true} do... | Capistrano::Configuration.instance(:must_exist).load do
after 'deploy', 'deploy:notify_hoptoad'
after 'deploy:migrations', 'deploy:notify_hoptoad'
namespace :deploy do
desc 'Notify Hoptoad of the deployment'
task :notify_hoptoad, :only => {:primary => true}, :except => {:no_release => true} do... |
Update hiredis dependency to 0.4.x | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "em-hiredis/version"
Gem::Specification.new do |s|
s.name = "em-hiredis"
s.version = EventMachine::Hiredis::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Martyn Loughran"]
s.email = ["me@mloughran.... | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "em-hiredis/version"
Gem::Specification.new do |s|
s.name = "em-hiredis"
s.version = EventMachine::Hiredis::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Martyn Loughran"]
s.email = ["me@mloughran.... |
Add a reply_to field for the helpdesk email | class ApplicationMailer < ActionMailer::Base
default from: ENV["MAILER_FROM"] || "no-reply@queens-awards-enterprise.service.gov.uk"
layout "mailer"
end
| class ApplicationMailer < ActionMailer::Base
default from: ENV["MAILER_FROM"] || "no-reply@queens-awards-enterprise.service.gov.uk",
reply_to: "info@queensawards.org.uk"
layout "mailer"
end
|
Revert "cleanup: rely on rubinius-compiler gem" | # The fancy_ext directory contains Rubinius-specific code (mostly
# extension methods) for existing classes that need to be defined in
# Ruby in order for Fancy to work correctly on rbx.
# The amount of code should be kept as small as possible, as we want
# to write as much in Fancy as possible.
base = File.dirname(__... | # The fancy_ext directory contains Rubinius-specific code (mostly
# extension methods) for existing classes that need to be defined in
# Ruby in order for Fancy to work correctly on rbx.
# The amount of code should be kept as small as possible, as we want
# to write as much in Fancy as possible.
base = File.dirname(__... |
Modify gemspec to prepare for publishing. | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bucketkit/version'
Gem::Specification.new do |spec|
spec.name = 'bucketkit'
spec.version = Bucketkit::VERSION
spec.authors = ['Xystushi']
spec.email = ['xystu... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bucketkit/version'
Gem::Specification.new do |spec|
spec.name = 'bucketkit'
spec.version = Bucketkit::VERSION
spec.authors = ['Xystushi']
spec.email = ['xystu... |
Drop timeouts to sane defaults | module BookingRequests
class Api
def create(booking_request)
connection.post '/api/v1/booking_requests', booking_request
true
end
private
def connection
HTTPConnectionFactory.build(api_uri, connection_options).tap do |c|
c.headers[:accept] = 'application/json'
c.au... | module BookingRequests
class Api
def create(booking_request)
connection.post '/api/v1/booking_requests', booking_request
true
end
private
def connection
HTTPConnectionFactory.build(api_uri, connection_options).tap do |c|
c.headers[:accept] = 'application/json'
c.au... |
Add missing require for 'cgi' | require 'uri'
require 'typhoeus'
require 'nokogiri'
require 'market_bot/version'
require 'market_bot/exceptions'
require 'market_bot/util'
require 'market_bot/play/constants'
require 'market_bot/play/app/constants'
require 'market_bot/play/app'
require 'market_bot/play/chart/constants'
require 'market_bot/play/chart'... | require 'uri'
require 'cgi'
require 'typhoeus'
require 'nokogiri'
require 'market_bot/version'
require 'market_bot/exceptions'
require 'market_bot/util'
require 'market_bot/play/constants'
require 'market_bot/play/app/constants'
require 'market_bot/play/app'
require 'market_bot/play/chart/constants'
require 'market_b... |
Fix Ruby 2.3 deprecation, timeout=>Timeout.timeout | module VCR
# Ruby 1.8 provides Ping.pingecho, but it was removed in 1.9.
# So we try requiring it, and if that fails, define it ourselves.
begin
require 'ping'
Ping = ::Ping
rescue LoadError
# This is copied, verbatim, from Ruby 1.8.7's ping.rb.
require 'timeout'
require "socket"
# @pri... | module VCR
# Ruby 1.8 provides Ping.pingecho, but it was removed in 1.9.
# So we try requiring it, and if that fails, define it ourselves.
begin
require 'ping'
Ping = ::Ping
rescue LoadError
# This is copied, verbatim, from Ruby 1.8.7's ping.rb.
require 'timeout'
require "socket"
# @pri... |
Fix bug showing Prayer Request in activity feed. | module FeedsHelper
end
| module FeedsHelper
def prayer_request_path(prayer_request)
group_prayer_request_path(prayer_request.group, prayer_request)
end
end
|
Use method syntax for accessing struct attributes. | module Lita
class Handler
extend Forwardable
attr_reader :redis
private :redis
def_delegators :@message, :args, :command?, :scan
class Route < Struct.new(:pattern, :method_name, :command)
alias_method :command?, :command
end
class << self
def route(pattern, to: nil, command... | module Lita
class Handler
extend Forwardable
attr_reader :redis
private :redis
def_delegators :@message, :args, :command?, :scan
class Route < Struct.new(:pattern, :method_name, :command)
alias_method :command?, :command
end
class << self
def route(pattern, to: nil, command... |
Use only one ItemFactory for both items and layouts | module Munge
class System
def initialize(root_path, config)
@root_path = root_path
@config = config
end
def items
return @items if @items
source_path = File.expand_path(@config[:source_path], @root_path)
source_item_factory =
ItemFactory.new(
text_extensi... | module Munge
class System
def initialize(root_path, config)
@root_path = root_path
@config = config
end
def item_factory
@item_factory ||=
ItemFactory.new(
text_extensions: @config[:items_text_extensions],
ignore_extensions: @config[:items_ignore_extensions]
... |
Add TransparencyData API Campaign Contributions support | module GovKit
class TransparencyDataResource < Resource
default_params :apikey => GovKit::configuration.sunlight_apikey
base_uri GovKit::configuration.transparency_data_base_url
end
module TransparencyData
# See http://transparencydata.com/api/contributions/
# for complete query options
class... | |
Add pagination div to filter. | module Liquid
module PaginationFilters
def paginate(pagination_info)
pagination_html = ""
if pagination_info.is_a?(Hash) && (pagination_info["current_page"] && pagination_info["per_page"] && pagination_info["total_entries"])
# Previous link, if appropriate
pagination_html += "<a h... | module Liquid
module PaginationFilters
def paginate(pagination_info)
pagination_html = ""
if pagination_info.is_a?(Hash) && (pagination_info["current_page"] && pagination_info["per_page"] && pagination_info["total_entries"])
pagination_html += "<div class=\"pagination\">"
... |
Fix inconsistency; no CommandHandler inheritance | require_relative 'helpers/self_applier'
require_relative 'helpers/uuid_helper'
module Sequent
module Core
# Base class for command handlers
# CommandHandlers are responsible for propagating a command to the correct Sequent::Core::AggregateRoot
# or creating a new one. For example:
#
# class Inv... | require_relative 'helpers/self_applier'
require_relative 'helpers/uuid_helper'
module Sequent
module Core
# Base class for command handlers
# CommandHandlers are responsible for propagating a command to the correct Sequent::Core::AggregateRoot
# or creating a new one. For example:
#
# class Inv... |
Remove extra attendance row spec | require 'rails_helper'
RSpec.describe AttendanceRow do
let(:absence) { '1' }
let(:tardy) { '0' }
let!(:student) { FactoryGirl.create(:student) }
let(:data) do
{
local_id: student.local_id,
event_date: DateTime.parse('1981-12-30'),
absence: absence,
tardy: tardy,
}
end
sub... | require 'rails_helper'
RSpec.describe AttendanceRow do
let(:absence) { '1' }
let(:tardy) { '0' }
let!(:student) { FactoryGirl.create(:student) }
let(:data) do
{
local_id: student.local_id,
event_date: DateTime.parse('1981-12-30'),
absence: absence,
tardy: tardy,
}
end
sub... |
Add fotorama images to precompile | # Used only for Ruby on Rails gem to tell, that gem contain `lib/assets`.
module Fotoramajs
module Rails
class Engine < ::Rails::Engine
end
end
end
| # Used only for Ruby on Rails gem to tell, that gem contain `lib/assets`.
module Fotoramajs
class Railtie < Rails::Railtie
initializer 'fotorama.config' do |app|
app.config.assets.precompile += ['fotorama.png', 'fotorama@2x.png']
end
end
module Rails
class Engine < ::Rails::Engine
end
end... |
Save screenshots in rdb tmp dir instead redmine tmp dir. |
module RdbRequestHelpers
def set_permissions
role = Role.where(:name => 'Manager').first
role.permissions << :view_dashboards
role.permissions << :configure_dashboards
role.save!
role = Role.where(:name => 'Developer').first
role.permissions << :view_dashboards
role.save!
# puts rol... |
module RdbRequestHelpers
def set_permissions
role = Role.where(:name => 'Manager').first
role.permissions << :view_dashboards
role.permissions << :configure_dashboards
role.save!
role = Role.where(:name => 'Developer').first
role.permissions << :view_dashboards
role.save!
# puts rol... |
Fix missing webrick error in ruby 3.0 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$:.unshift(lib) unless $:.include?(lib)
require 'favicon_party/version'
Gem::Specification.new do |s|
s.name = "favicon_party"
s.version = FaviconParty::VERSION
s.authors = ["Linmiao Xu"]
s.email = ["linmiao.xu@gmail... | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$:.unshift(lib) unless $:.include?(lib)
require 'favicon_party/version'
Gem::Specification.new do |s|
s.name = "favicon_party"
s.version = FaviconParty::VERSION
s.authors = ["Linmiao Xu"]
s.email = ["linmiao.xu@gmail... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.