Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Change gemspec to avoid subshells and remove unneeded files | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "simple_form/version"
Gem::Specification.new do |s|
s.name = "simple_form"
s.version = SimpleForm::VERSION.dup
s.platform = Gem::Platform::RUBY
s.summary = "Forms made easy!"
s.email = "contact@plataformatec.com.br"
s.homepage = "http://github.com/plataformatec/simple_form"
s.description = "Forms made easy!"
s.authors = ['José Valim', 'Carlos Antônio']
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.test_files -= Dir["test/support/country_select/**/*"]
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.rubyforge_project = "simple_form"
s.add_dependency('activemodel', '>= 3.0.0.rc', '< 4.0')
s.add_dependency('actionpack', '>= 3.0.0.rc', '< 4.0')
end
| # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "simple_form/version"
Gem::Specification.new do |s|
s.name = "simple_form"
s.version = SimpleForm::VERSION.dup
s.platform = Gem::Platform::RUBY
s.summary = "Forms made easy!"
s.email = "contact@plataformatec.com.br"
s.homepage = "http://github.com/plataformatec/simple_form"
s.description = "Forms made easy!"
s.authors = ['José Valim', 'Carlos Antônio']
s.files = Dir["CHANGELOG.md", "MIT-LICENSE", "README.md", "lib/**/*"]
s.test_files = Dir["test/**/*"]
s.test_files -= Dir["test/support/country_select/**/*"]
s.require_paths = ["lib"]
s.rubyforge_project = "simple_form"
s.add_dependency('activemodel', '>= 3.0.0.rc', '< 4.0')
s.add_dependency('actionpack', '>= 3.0.0.rc', '< 4.0')
end
|
Rename "not" to "not!" to avoid conflicts with the ruby keyword | require 'discordrb/events/utility'
def not(object)
Negated.new(object)
end
module Discordrb::Events
class Negated
attr_reader :object
def initialize(object); @object = object; end
end
def matches_all(attributes, to_check, &block)
# "Zeroth" case: attributes is nil
return true unless attributes
# First case: there's only a single attribute
unless attributes.is_a? Array
return yield(attributes, to_check)
end
# Second case: it's an array of attributes
attributes.reduce(false) { |result, element| result || yield(element, to_check) }
end
class EventHandler
def initialize(attributes, block)
@attributes = attributes
@block = block
end
def matches?(event)
raise "Attempted to call matches?() from a generic EventHandler"
end
def match(event)
@block.call(event) if matches? event
end
end
# Event handler that matches all events
class TrueEventHandler < EventHandler
def matches?(event)
true
end
end
end
| require 'discordrb/events/utility'
def not!(object)
Negated.new(object)
end
module Discordrb::Events
class Negated
attr_reader :object
def initialize(object); @object = object; end
end
def matches_all(attributes, to_check, &block)
# "Zeroth" case: attributes is nil
return true unless attributes
# First case: there's only a single attribute
unless attributes.is_a? Array
return yield(attributes, to_check)
end
# Second case: it's an array of attributes
attributes.reduce(false) { |result, element| result || yield(element, to_check) }
end
class EventHandler
def initialize(attributes, block)
@attributes = attributes
@block = block
end
def matches?(event)
raise "Attempted to call matches?() from a generic EventHandler"
end
def match(event)
@block.call(event) if matches? event
end
end
# Event handler that matches all events
class TrueEventHandler < EventHandler
def matches?(event)
true
end
end
end
|
Change Google Chrome Canary homepage to HTTPS | class GoogleChromeCanary < Cask
url 'https://storage.googleapis.com/chrome-canary/GoogleChromeCanary.dmg'
homepage 'http://www.google.com/chrome/browser/canary.html'
version 'latest'
sha256 :no_check
link 'Google Chrome Canary.app'
end
| class GoogleChromeCanary < Cask
url 'https://storage.googleapis.com/chrome-canary/GoogleChromeCanary.dmg'
homepage 'https://www.google.com/chrome/browser/canary.html'
version 'latest'
sha256 :no_check
link 'Google Chrome Canary.app'
end
|
Optimize SQL query that removes duplicated stages | class RemoveRedundantPipelineStages < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
redundant_stages_ids = <<~SQL
SELECT id FROM ci_stages a WHERE (
SELECT COUNT(*) FROM ci_stages b
WHERE a.pipeline_id = b.pipeline_id AND a.name = b.name
) > 1
SQL
execute <<~SQL
UPDATE ci_builds SET stage_id = NULL WHERE ci_builds.stage_id IN (#{redundant_stages_ids})
SQL
execute <<~SQL
DELETE FROM ci_stages WHERE ci_stages.id IN (#{redundant_stages_ids})
SQL
end
def down
# noop
end
end
| class RemoveRedundantPipelineStages < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
redundant_stages_ids = <<~SQL
SELECT id FROM ci_stages WHERE (pipeline_id, name) IN (
SELECT pipeline_id, name FROM ci_stages
GROUP BY pipeline_id, name HAVING COUNT(*) > 1
)
SQL
execute <<~SQL
UPDATE ci_builds SET stage_id = NULL WHERE ci_builds.stage_id IN (#{redundant_stages_ids})
SQL
execute <<~SQL
DELETE FROM ci_stages WHERE ci_stages.id IN (#{redundant_stages_ids})
SQL
end
def down
# noop
end
end
|
Update OpenEmu Experimental to version 1.0.3 | class OpenemuExperimental < Cask
url 'https://github.com/OpenEmu/OpenEmu/releases/download/v1.0.2/OpenEmu_1.0.2-experimental.zip'
homepage 'http://openemu.org/'
version '1.0.2'
sha256 '0914ea5b43b38fdebbbae51f3e080f244882d99b9d0c90d1a592f5c2023df107'
link 'OpenEmu.app'
end
| class OpenemuExperimental < Cask
url 'https://github.com/OpenEmu/OpenEmu/releases/download/v1.0.3/OpenEmu_1.0.3-experimental.zip'
homepage 'http://openemu.org/'
version '1.0.3'
sha256 'cc5dce40a25ab224991ec0a8f772673983e81daa3b49f332e03d14e3b97d5b2e'
link 'OpenEmu.app'
end
|
Move IntelliJ Ultimate 12 to caskroom | class IntellijIdeaUltimate12 < Cask
url 'http://download.jetbrains.com/idea/ideaIU-12.1.6.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
version '12.1.6'
sha1 '4d0cb823bf0ff154357aedc1eee8eca3974556a3'
link 'IntelliJ IDEA 12.app'
end
| |
Make a mock for Discordrb::API to allow setting arbitrary request parameters and responses | # Mock for Discordrb::API that allows setting arbitrary results and checking previous requests
require 'json'
module APIMock
refine Discordrb::API.singleton_class do
attr_reader :last_method
attr_reader :last_url
attr_reader :last_body
attr_reader :last_headers
attr_writer :next_response
def raw_request(type, attributes)
@last_method = type
@last_url = attributes.first
@last_body = attributes[1].is_a?(Hash) ? nil : JSON.parse(attributes[1]) if attributes[1]
@last_headers = attributes.last
@next_response
end
end
end
| |
Update 1Password.app to version 5.3.BETA-17 | cask :v1 => '1password-beta' do
version '5.3.BETA-16'
sha256 '173e337ec6b2636579ce5362401f714b18808daa69e734a35c5615b0cdddf019'
url "https://cache.agilebits.com/dist/1P/mac4/1Password-#{version}.zip"
name '1Password'
homepage 'https://agilebits.com/onepassword/mac'
license :commercial
app '1Password 5.app'
zap :delete => [
'~/Library/Application Scripts/2BUA8C4S2C.com.agilebits.onepassword-osx-helper',
'~/Library/Containers/2BUA8C4S2C.com.agilebits.onepassword-osx-helper',
'~/Library/Containers/com.agilebits.onepassword-osx',
'~/Library/Group Containers/2BUA8C4S2C.com.agilebits',
]
end
| cask :v1 => '1password-beta' do
version '5.3.BETA-17'
sha256 'faa9f98a2b1cddc5a5f7479ae6a3effea8db99e206100fae02566a97a5b8efb8'
url "https://cache.agilebits.com/dist/1P/mac4/1Password-#{version}.zip"
name '1Password'
homepage 'https://agilebits.com/onepassword/mac'
license :commercial
app '1Password 5.app'
zap :delete => [
'~/Library/Application Scripts/2BUA8C4S2C.com.agilebits.onepassword-osx-helper',
'~/Library/Containers/2BUA8C4S2C.com.agilebits.onepassword-osx-helper',
'~/Library/Containers/com.agilebits.onepassword-osx',
'~/Library/Group Containers/2BUA8C4S2C.com.agilebits',
]
end
|
Use File.join the right way (more than one sub-path argument). | # encoding: UTF-8
module TwitterCldr
module Normalizers
class Base
def unicode_data
data_path = File.join("#{File.dirname(__FILE__)}/data/")
index = {}
IO.readlines(File.join(data_path, 'UnicodeData.txt')).map do |line|
property = line.split(';')
code_point = property.first
index[code_point] = property
end
index
end
end
end
end | # encoding: UTF-8
module TwitterCldr
module Normalizers
class Base
def unicode_data
data_path = File.join(File.dirname(__FILE__), "data")
index = {}
IO.readlines(File.join(data_path, 'UnicodeData.txt')).map do |line|
property = line.split(';')
code_point = property.first
index[code_point] = property
end
index
end
end
end
end |
Change language for testing colour fallback | require 'spec_helper'
describe Projects::GraphsController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
project.team << [user, :master]
end
describe 'GET #languages' do
let(:linguist_repository) do
double(languages: {
'Ruby' => 1000,
'CoffeeScript' => 350,
'PowerShell' => 15
})
end
let(:expected_values) do
ps_color = "##{Digest::SHA256.hexdigest('PowerShell')[0...6]}"
[
# colors from Linguist:
{ label: "Ruby", color: "#701516", highlight: "#701516" },
{ label: "CoffeeScript", color: "#244776", highlight: "#244776" },
# colors from SHA256 fallback:
{ label: "PowerShell", color: ps_color, highlight: ps_color }
]
end
before do
allow(Linguist::Repository).to receive(:new).and_return(linguist_repository)
end
it 'sets the correct colour according to language' do
get(:languages, namespace_id: project.namespace, project_id: project, id: 'master')
expected_values.each do |val|
expect(assigns(:languages)).to include(a_hash_including(val))
end
end
end
end
| require 'spec_helper'
describe Projects::GraphsController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
project.team << [user, :master]
end
describe 'GET #languages' do
let(:linguist_repository) do
double(languages: {
'Ruby' => 1000,
'CoffeeScript' => 350,
'NSIS' => 15
})
end
let(:expected_values) do
nsis_color = "##{Digest::SHA256.hexdigest('NSIS')[0...6]}"
[
# colors from Linguist:
{ label: "Ruby", color: "#701516", highlight: "#701516" },
{ label: "CoffeeScript", color: "#244776", highlight: "#244776" },
# colors from SHA256 fallback:
{ label: "NSIS", color: nsis_color, highlight: nsis_color }
]
end
before do
allow(Linguist::Repository).to receive(:new).and_return(linguist_repository)
end
it 'sets the correct colour according to language' do
get(:languages, namespace_id: project.namespace, project_id: project, id: 'master')
expected_values.each do |val|
expect(assigns(:languages)).to include(a_hash_including(val))
end
end
end
end
|
Add tests for pagination module extracted from API | require 'spec_helper'
describe API::Helpers::Pagination do
let(:resource) { Project.all }
subject do
Class.new.include(described_class).new
end
describe '#paginate' do
let(:value) { spy('return value') }
before do
allow(value).to receive(:to_query).and_return(value)
allow(subject).to receive(:header).and_return(value)
allow(subject).to receive(:params).and_return(value)
allow(subject).to receive(:request).and_return(value)
end
describe 'required instance methods' do
let(:return_spy) { spy }
it 'requires some instance methods' do
expect_message(:header)
expect_message(:params)
expect_message(:request)
subject.paginate(resource)
end
end
context 'when resource can be paginated' do
before do
create_list(:empty_project, 3)
end
describe 'first page' do
before do
allow(subject).to receive(:params)
.and_return({ page: 1, per_page: 2 })
end
it 'returns appropriate amount of resources' do
expect(subject.paginate(resource).count).to eq 2
end
it 'adds appropriate headers' do
expect_header('X-Total', '3')
expect_header('X-Total-Pages', '2')
expect_header('X-Per-Page', '2')
expect_header('X-Page', '1')
expect_header('X-Next-Page', '2')
expect_header('X-Prev-Page', '')
expect_header('Link', any_args)
subject.paginate(resource)
end
end
describe 'second page' do
before do
allow(subject).to receive(:params)
.and_return({ page: 2, per_page: 2 })
end
it 'returns appropriate amount of resources' do
expect(subject.paginate(resource).count).to eq 1
end
it 'adds appropriate headers' do
expect_header('X-Total', '3')
expect_header('X-Total-Pages', '2')
expect_header('X-Per-Page', '2')
expect_header('X-Page', '2')
expect_header('X-Next-Page', '')
expect_header('X-Prev-Page', '1')
expect_header('Link', any_args)
subject.paginate(resource)
end
end
end
def expect_header(name, value)
expect(subject).to receive(:header).with(name, value)
end
def expect_message(method)
expect(subject).to receive(method)
.at_least(:once).and_return(value)
end
end
end
| |
Update Navicat Premium to 11.0.15 | class NavicatPremium < Cask
url 'http://download.navicat.com/download/navicat110_premium_en.dmg'
homepage 'http://www.navicat.com/products/navicat-premium'
version '11.0.14'
sha1 '5c33766a606cda288964fc05bd485f0673da4614'
link 'Navicat Premium.app'
end
| class NavicatPremium < Cask
url 'http://download.navicat.com/download/navicat110_premium_en.dmg'
homepage 'http://www.navicat.com/products/navicat-premium'
version '11.0.15'
sha256 '15771c07291a1d06d965cbe742a7c4607b568052f1bbf830829f10bf8f447a22'
link 'Navicat Premium.app'
end
|
Return permissions for orders within the API results | object @order
extends "spree/api/orders/order"
if lookup_context.find_all("spree/api/orders/#{root_object.state}").present?
extends "spree/api/orders/#{root_object.state}"
end
child :billing_address => :bill_address do
extends "spree/api/addresses/show"
end
child :shipping_address => :ship_address do
extends "spree/api/addresses/show"
end
child :line_items => :line_items do
extends "spree/api/line_items/show"
end
child :payments => :payments do
attributes *payment_attributes
child :payment_method => :payment_method do
attributes :id, :name, :environment
end
child :source => :source do
attributes *payment_source_attributes
end
end
child :shipments => :shipments do
extends "spree/api/shipments/small"
end
child :adjustments => :adjustments do
extends "spree/api/adjustments/show"
end
| object @order
extends "spree/api/orders/order"
if lookup_context.find_all("spree/api/orders/#{root_object.state}").present?
extends "spree/api/orders/#{root_object.state}"
end
child :billing_address => :bill_address do
extends "spree/api/addresses/show"
end
child :shipping_address => :ship_address do
extends "spree/api/addresses/show"
end
child :line_items => :line_items do
extends "spree/api/line_items/show"
end
child :payments => :payments do
attributes *payment_attributes
child :payment_method => :payment_method do
attributes :id, :name, :environment
end
child :source => :source do
attributes *payment_source_attributes
end
end
child :shipments => :shipments do
extends "spree/api/shipments/small"
end
child :adjustments => :adjustments do
extends "spree/api/adjustments/show"
end
# Necessary for backend's order interface
node :permissions do
{ can_update: current_ability.can?(:update, root_object) }
end |
Add code wars 6 playing with digits | # http://www.codewars.com/kata/5552101f47fc5178b1000050/
# --- iteration 1 ---
def dig_pow(n, p)
n_digs = n.to_s.chars.map(&:to_i)
p_digs = (p...(p + n_digs.count)).to_a
x = n_digs.each_with_index.reduce(0) do |acc, (el, i)|
acc + el ** p_digs[i]
end
x.to_f / n % 1 == 0 ? x / n : -1
end
# --- iteration 2 ---
def dig_pow(n, p)
sum = n.to_s.chars.map(&:to_i).each_with_index.reduce(0) do |acc, (el, i)|
acc += el**(p + i)
end
sum % n == 0 ? sum/n : -1
end
| |
Update spec to match the new behavior of stacks | require "spec_helper"
require "heroku/command/stack"
module Heroku::Command
describe Stack do
describe "index" do
before(:each) do
stub_core
api.post_app("name" => "example", "stack" => "bamboo-mri-1.9.2")
end
after(:each) do
api.delete_app("example")
end
it "index should provide list" do
stderr, stdout = execute("stack")
expect(stderr).to eq("")
expect(stdout).to eq <<-STDOUT
=== example Available Stacks
aspen-mri-1.8.6
bamboo-ree-1.8.7
cedar (beta)
* bamboo-mri-1.9.2
STDOUT
end
it "migrate should succeed" do
stderr, stdout = execute("stack:migrate bamboo-ree-1.8.7")
expect(stderr).to eq("")
expect(stdout).to eq <<-STDOUT
Stack set. Next release on example will use bamboo-ree-1.8.7.
Run `git push heroku master` to create a new release on bamboo-ree-1.8.7.
STDOUT
end
end
end
end
| require "spec_helper"
require "heroku/command/stack"
module Heroku::Command
describe Stack do
describe "index" do
before(:each) do
stub_core
api.post_app("name" => "example", "stack" => "bamboo-mri-1.9.2")
end
after(:each) do
api.delete_app("example")
end
it "index should provide list" do
stderr, stdout = execute("stack")
expect(stderr).to eq("")
expect(stdout).to eq <<-STDOUT
=== example Available Stacks
aspen-mri-1.8.6
bamboo-ree-1.8.7
cedar-10 (beta)
* bamboo-mri-1.9.2
STDOUT
end
it "migrate should succeed" do
stderr, stdout = execute("stack:migrate bamboo-ree-1.8.7")
expect(stderr).to eq("")
expect(stdout).to eq <<-STDOUT
Stack set. Next release on example will use bamboo-ree-1.8.7.
Run `git push heroku master` to create a new release on bamboo-ree-1.8.7.
STDOUT
end
end
end
end
|
Add SingleXLSX.open method to write XLSX file | require "single_xlsx/sheet"
module SingleXLSX
module Writing
def generate
raise ArgumentError, "no block given" unless block_given?
book = RubyXL::Workbook.new
sheet = Sheet.new(book[0])
yield sheet
book.stream.read
end
end
extend Writing
end
| require "single_xlsx/sheet"
module SingleXLSX
module Writing
def generate(&block)
create_book(&block).stream.read
end
def open(path, &block)
create_book(&block).write(path)
end
private
def create_book(&block)
raise ArgumentError, "no block given" if block.nil?
book = RubyXL::Workbook.new
sheet = Sheet.new(book[0])
block.call(sheet)
book
end
end
extend Writing
end
|
Remove oj (Yajl is fine again) | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'chefspec/version'
Gem::Specification.new do |s|
s.name = 'chefspec'
s.version = ChefSpec::VERSION
s.description = 'Write RSpec examples for Opscode Chef recipes'
s.summary = "chefspec-#{s.version}"
s.authors = ['Andrew Crump', 'Seth Vargo']
s.homepage = 'http://acrmp.github.com/chefspec'
s.license = 'MIT'
s.require_path = 'lib'
s.required_ruby_version = '>= 1.9'
s.files = Dir['lib/**/*.rb']
s.add_dependency 'chef', '~> 11.0'
s.add_dependency 'fauxhai', '~> 2.0'
s.add_dependency 'rspec', '~> 2.14'
# Development Dependencies
s.add_development_dependency 'rake'
s.add_development_dependency 'redcarpet', '~> 3.0'
s.add_development_dependency 'yard', '~> 0.8'
# Testing Dependencies
s.add_development_dependency 'aruba', '~> 0.5'
s.add_development_dependency 'oj', '~> 2.1'
end
| lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'chefspec/version'
Gem::Specification.new do |s|
s.name = 'chefspec'
s.version = ChefSpec::VERSION
s.description = 'Write RSpec examples for Opscode Chef recipes'
s.summary = "chefspec-#{s.version}"
s.authors = ['Andrew Crump', 'Seth Vargo']
s.homepage = 'http://acrmp.github.com/chefspec'
s.license = 'MIT'
s.require_path = 'lib'
s.required_ruby_version = '>= 1.9'
s.files = Dir['lib/**/*.rb']
s.add_dependency 'chef', '~> 11.0'
s.add_dependency 'fauxhai', '~> 2.0'
s.add_dependency 'rspec', '~> 2.14'
# Development Dependencies
s.add_development_dependency 'rake'
s.add_development_dependency 'redcarpet', '~> 3.0'
s.add_development_dependency 'yard', '~> 0.8'
# Testing Dependencies
s.add_development_dependency 'aruba', '~> 0.5'
end
|
Add upstart for three scalable processes. |
template "/etc/init/ripple_gateway.conf" do
source "ripple_gateway.conf.erb"
action :create
end
|
template "/etc/init/ripple_gateway.conf" do
source "ripple_gateway.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-webapp.conf" do
source "ripple_gateway-webapp.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-webapp-1.conf" do
source "ripple_gateway-webapp-1.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-incoming_ripple_payments.conf" do
source "ripple_gateway-incoming_ripple_payments.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-incoming_ripple_payments-1.conf" do
source "ripple_gateway-incoming_ripple_payments-1.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-outgoing_ripple_payments.conf" do
source "ripple_gateway-outgoing_ripple_payments.conf.erb"
action :create
end
template "/etc/init/ripple_gateway-outgoing_ripple_payments-1.conf" do
source "ripple_gateway-outgoing_ripple_payments-1.conf.erb"
action :create
end
|
Add tests for yaml content with errors | require 'spec_helper'
describe API::API do
include ApiHelpers
let(:user) { create(:user) }
let(:yaml_content) do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
describe 'POST /lint' do
context 'with valid .gitlab-ci.yaml content' do
context 'authorized user' do
it 'validate content' do
post api('/lint'), { content: yaml_content }
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid')
end
end
end
context 'with invalid .gitlab_ci.yml content' do
it 'validate content' do
post api('/lint'), { content: 'invalid content' }
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
end
end
context 'no content parameters' do
it 'shows error message' do
post api('/lint')
expect(response).to have_http_status(400)
end
end
end
end
| require 'spec_helper'
describe API::API do
include ApiHelpers
let(:yaml_content) do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
describe 'POST /lint' do
context 'with valid .gitlab-ci.yaml content' do
it 'validates content' do
post api('/lint'), { content: yaml_content }
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid')
end
end
context 'with invalid .gitlab_ci.yml' do
it 'validates content and shows correct errors' do
post api('/lint'), { content: 'invalid content' }
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
expect(json_response['errors']).to eq(['Invalid configuration format'])
end
it "validates content and shows configuration error" do
post api('/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' }
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
end
end
context 'no content parameters' do
it 'shows error message' do
post api('/lint')
expect(response).to have_http_status(400)
end
end
end
end
|
Update PHPStorm EAP to 141.1306 | cask :v1 => 'phpstorm-eap' do
version '141.891'
sha256 '5fca9d16de932905109decc442889f1534b5e77b5226ff15c77bd8259aa88ec0'
url "http://download.jetbrains.com/webide/PhpStorm-EAP-#{version}.dmg"
homepage 'http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program'
license :commercial
app 'PhpStorm EAP.app'
postflight do
plist_set(':JVMOptions:JVMVersion', '1.6+')
end
zap :delete => [
'~/Library/Application Support/WebIde80',
'~/Library/Preferences/WebIde80',
'~/Library/Preferences/com.jetbrains.PhpStorm-EAP.plist',
]
end
| cask :v1 => 'phpstorm-eap' do
version '141.1306'
sha256 'ebd04e0378cb2d5c528bb9e7618dbb89ddb1d9e7f9e429cd21594e622194a7e2'
url "http://download.jetbrains.com/webide/PhpStorm-EAP-#{version}.dmg"
homepage 'http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program'
license :commercial
app 'PhpStorm EAP.app'
postflight do
plist_set(':JVMOptions:JVMVersion', '1.6+')
end
zap :delete => [
'~/Library/Application Support/WebIde80',
'~/Library/Preferences/WebIde80',
'~/Library/Preferences/com.jetbrains.PhpStorm-EAP.plist',
]
end
|
Add Rake task for releasing docs | require 'yard'
require 'yard/rake/yardoc_task'
require 'cucumber/platform'
YARD::Templates::Engine.register_template_path(File.expand_path(File.join(File.dirname(__FILE__), 'yard')))
YARD::Rake::YardocTask.new(:yard) do |t|
t.options = %w{--no-private --title Cucumber}
t.files = %w{lib - README.md History.md LICENSE}
end
desc "Push yardoc to http://cukes.info/cucumber/api/#{Cucumber::VERSION}"
task :push_yard => :yard do
sh("tar czf api-#{Cucumber::VERSION}.tgz -C doc .")
sh("scp api-#{Cucumber::VERSION}.tgz cukes.info:/var/www/cucumber/api/ruby")
sh("ssh cukes.info 'cd /var/www/cucumber/api/ruby && rm -rf #{Cucumber::VERSION} && mkdir #{Cucumber::VERSION} && tar xzf api-#{Cucumber::VERSION}.tgz -C #{Cucumber::VERSION} && rm -f latest && ln -s #{Cucumber::VERSION} latest'")
end
#task :release => :push_yard
| require 'yard'
require 'yard/rake/yardoc_task'
require_relative '../lib/cucumber/platform'
SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../../cucumber.github.com')
API_DIR = File.join(SITE_DIR, 'api', 'cucumber', 'ruby', 'yardoc')
namespace :api do
file :dir do
unless File.directory?(SITE_DIR)
raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}"
end
mkdir_p API_DIR
end
template_path = File.expand_path(File.join(File.dirname(__FILE__), 'yard'))
YARD::Templates::Engine.register_template_path(template_path)
YARD::Rake::YardocTask.new(:yard) do |yard|
dir = API_DIR
mkdir_p dir
yard.options = ["--out", dir]
end
task :yard => :dir
task :release do
Dir.chdir(SITE_DIR) do
sh('git add .')
sh("git commit -m 'Update API docs for Cucumber v#{Cucumber::VERSION}'")
sh('git push')
end
end
desc "Generate YARD docs for Cucumber's API"
task :doc => [:yard, :release]
end
|
Update Vagrant Manager to 2.3.0 | cask :v1 => 'vagrant-manager' do
version '2.2.1'
sha256 'c9d63396cb322c65573a3a0c54dd700db18cff736b0f8b21a7813ac51d6ea5dd'
# github.com is the official download host per the vendor homepage
url "https://github.com/lanayotech/vagrant-manager/releases/download/#{version}/vagrant-manager-#{version}.dmg"
appcast 'http://api.lanayo.com/appcast/vagrant_manager.xml',
:sha256 => '599d9d60e76b718094569353ddd31850cdd3efaed6de61d320f53e7bf83073fb'
name 'Vagrant Manager'
homepage 'http://vagrantmanager.com/'
license :mit
app 'Vagrant Manager.app'
end
| cask :v1 => 'vagrant-manager' do
version '2.3.0'
sha256 'a9d308999a03b39658546c122e55580fdcbda7d3acd0b9ce0228cd3bcad053bf'
# github.com is the official download host per the vendor homepage
url "https://github.com/lanayotech/vagrant-manager/releases/download/#{version}/vagrant-manager-#{version}.dmg"
appcast 'http://api.lanayo.com/appcast/vagrant_manager.xml',
:sha256 => '706d0efbb0f4cad1fb74c7ae2ce7b0c2cfed40c7d82881b418e2df014f9fd730'
name 'Vagrant Manager'
homepage 'http://vagrantmanager.com/'
license :mit
app 'Vagrant Manager.app'
end
|
Update attrs for system-info 2.0.1 | include_attribute 'travis_build_environment'
default['travis_system_info']['commands_file'] = '/usr/local/system_info/commands.yml'
default['travis_system_info']['defaults_file'] = '/etc/default/travis-system-info'
default['travis_system_info']['dest_dir'] = '/usr/share/travis'
default['travis_system_info']['gem_url'] = 'https://s3.amazonaws.com/travis-system-info/system-info-2.0.0.gem'
default['travis_system_info']['gem_sha256sum'] = nil
default['travis_system_info']['travis_cookbooks_sha'] = 'fffffff'
| include_attribute 'travis_build_environment'
default['travis_system_info']['commands_file'] = '/usr/local/system_info/commands.yml'
default['travis_system_info']['defaults_file'] = '/etc/default/travis-system-info'
default['travis_system_info']['dest_dir'] = '/usr/share/travis'
default['travis_system_info']['gem_url'] = 'https://s3.amazonaws.com/travis-system-info/system-info-2.0.1.gem'
default['travis_system_info']['gem_sha256sum'] = 'd74319bcfdcc9d2912c3121c66a7c8dc360664a9995b46a4c03b5fbb1e63665f'
default['travis_system_info']['travis_cookbooks_sha'] = 'fffffff'
|
Add missing group extension module | module OmfEc
module GroupExt
@@methods_to_fwd = []
def fwd_method_to_aliases(*m)
@@methods_to_fwd += m.flatten
end
def method_added(m)
if @@methods_to_fwd.delete(m)
alias_method "#{m}_without_fwd_to_aliases", m
define_method m do |*args, &block|
method("#{m}_without_fwd_to_aliases").call(*args, &block)
self.g_aliases.each { |g| g.send(m, *args, &block) }
end
end
end
end
end
| |
Switch to %.( like rubocop says | apt_repository 'mercurial' do
uri 'ppa:mercurial-ppa/releases'
distribution node['lsb']['codename']
keyserver 'hkp://ha.pool.sks-keyservers.net'
retries 2
retry_delay 30
end
package %w[mercurial-common mercurial] do
action %i[install upgrade]
end
| apt_repository 'mercurial' do
uri 'ppa:mercurial-ppa/releases'
distribution node['lsb']['codename']
keyserver 'hkp://ha.pool.sks-keyservers.net'
retries 2
retry_delay 30
end
package %w(mercurial-common mercurial) do
action %i(install upgrade)
end
|
Update to latest versioning scheme | class Apptivate < Cask
url 'http://www.apptivateapp.com/resources/Apptivate.app.zip'
homepage 'http://www.apptivateapp.com'
version '2.1_12'
sha1 '6135ba88e2aa3b6141c6a2a76cd4142518ba35fc'
link 'Apptivate.app'
end
| class Apptivate < Cask
url 'http://www.apptivateapp.com/resources/Apptivate.app.zip'
homepage 'http://www.apptivateapp.com'
version 'latest'
no_checksum
link 'Apptivate.app'
end
|
Update PhpStorm EAP to v138.2502 | class PhpstormEap < Cask
version '138.2071'
sha256 'f0c52920fdce0ca3f1001342e816e5283c3efe502a1b0d39667332b4afeced87'
url "http://download.jetbrains.com/webide/PhpStorm-EAP-#{version}.dmg"
homepage 'http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program'
app 'PhpStorm EAP.app'
end
| class PhpstormEap < Cask
version '138.2502'
sha256 '61c1872a4e487f955956cba93eb8a2f5f743c8dd1aff1eac1c96555b306cdb81'
url "http://download.jetbrains.com/webide/PhpStorm-EAP-#{version}.dmg"
homepage 'http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program'
app 'PhpStorm EAP.app'
end
|
Change my e-mail to @rts.ch in podspec | Pod::Spec.new do |s|
s.name = "RTSMediaPlayer"
s.version = "0.0.1"
s.summary = "Shared media player for RTS mobile apps."
s.homepage = "ssh://git@bitbucket.org:rtsmb/rtsmediaplayer-ios.git"
s.authors = { "Frédéric Humbert-Droz" => "fred.hd@me.com", "Cédric Luthi" => "cedric.luthi@gmail.com" }
s.source = { :git => "ssh://git@bitbucket.org:rtsmb/rtsmediaplayer-ios.git", :branch => "master", :tag => "#{s.version}" }
s.ios.deployment_target = "7.0"
s.requires_arc = true
s.source_files = "RTSMediaPlayer"
s.public_header_files = "RTSMediaPlayer/*.h"
s.resource_bundle = { "RTSMediaPlayer" => ["RTSMediaPlayer/*.xib"] }
s.dependency "TransitionKit", "2.1.1"
end
| Pod::Spec.new do |s|
s.name = "RTSMediaPlayer"
s.version = "0.0.1"
s.summary = "Shared media player for RTS mobile apps."
s.homepage = "ssh://git@bitbucket.org:rtsmb/rtsmediaplayer-ios.git"
s.authors = { "Frédéric Humbert-Droz" => "fred.hd@me.com", "Cédric Luthi" => "cedric.luthi@rts.ch" }
s.source = { :git => "ssh://git@bitbucket.org:rtsmb/rtsmediaplayer-ios.git", :branch => "master", :tag => "#{s.version}" }
s.ios.deployment_target = "7.0"
s.requires_arc = true
s.source_files = "RTSMediaPlayer"
s.public_header_files = "RTSMediaPlayer/*.h"
s.resource_bundle = { "RTSMediaPlayer" => ["RTSMediaPlayer/*.xib"] }
s.dependency "TransitionKit", "2.1.1"
end
|
Add multiple push_routes as a test to rspec. | require 'spec_helper'
describe 'openvpn::server' do
let(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['openvpn_conf']) do |node|
node.set['openvpn']['push_options'] = {
'dhcp-options' => ['DOMAIN local',
'DOMAIN-SEARCH local']
}
end.converge(described_recipe)
end
it 'converges' do
chef_run
end
it 'makes a template with dhcp options' do
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "dhcp-options DOMAIN local"')
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "dhcp-options DOMAIN-SEARCH local"')
end
end
| require 'spec_helper'
describe 'openvpn::server' do
let(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['openvpn_conf']) do |node|
node.set['openvpn']['push_options'] = {
'dhcp-options' => ['DOMAIN local',
'DOMAIN-SEARCH local']
}
node.set['openvpn']['push_routes'] = [
'192.168.10.0 255.255.255.0', '10.12.10.0 255.255.255.0'
]
end.converge(described_recipe)
end
it 'converges' do
chef_run
end
it 'makes a server.conf from template with dhcp options' do
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "dhcp-options DOMAIN local"')
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "dhcp-options DOMAIN-SEARCH local"')
end
it 'makes a server.conf from template with multiple push routes' do
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "route 192.168.10.0 255.255.255.0"')
expect(chef_run).to render_file('/etc/openvpn/server.conf')
.with_content('push "route 10.12.10.0 255.255.255.0"')
end
end
|
Reconfigure mysql-apt-config and update package list | # set up mysql-apt-config
apt_config_file = File.join(Chef::Config[:file_cache_path], 'mysql-apt-config.deb')
remote_file apt_config_file do
source "http://dev.mysql.com/get/mysql-apt-config_#{node.mysql.deb.config.version}-2ubuntu#{node.platform_version}_all.deb"
end
execute "preseed mysql-apt-config" do
command "debconf-set-selections /var/cache/local/preseeding/mysql-apt-config.seed"
action :nothing
end
template "/var/cache/local/preseeding/mysql-apt-config.seed" do
source "mysql-apt-config.seed.erb"
owner "root"
group "root"
mode "0600"
notifies :run, resources(:execute => "preseed mysql-apt-config"), :immediately
end
dpkg_package 'mysql-apt-config' do
source apt_config_file
end
| # set up mysql-apt-config
apt_config_file = File.join(Chef::Config[:file_cache_path], 'mysql-apt-config.deb')
remote_file apt_config_file do
source "http://dev.mysql.com/get/mysql-apt-config_#{node.mysql.deb.config.version}-2ubuntu#{node.platform_version}_all.deb"
end
execute "preseed mysql-apt-config" do
command "debconf-set-selections /var/cache/local/preseeding/mysql-apt-config.seed"
action :nothing
end
template "/var/cache/local/preseeding/mysql-apt-config.seed" do
source "mysql-apt-config.seed.erb"
owner "root"
group "root"
mode "0600"
notifies :run, resources(:execute => "preseed mysql-apt-config"), :immediately
end
dpkg_package 'mysql-apt-config' do
source apt_config_file
end
execute 'reconfigure mysql-apt-config' do
command 'dpkg-reconfigure mysql-apt-config'
end
execute 'update APT packag list' do
command 'apt-get update -qq'
end
|
Update Google App Engine to 1.9.28 | cask :v1 => 'googleappengine' do
version '1.9.25'
sha256 'e3b69ef42262477a2e925783a8ce8856d81ffc4535595bd43d2d57d1e7d1c3ac'
# googleapis.com is the official download host per the vendor homepage
url "https://storage.googleapis.com/appengine-sdks/featured/GoogleAppEngineLauncher-#{version}.dmg"
appcast 'https://storage.googleapis.com/appengine-sdks',
:sha256 => '4981d218798ee2a124921c980c8c8a71b3538ddeb6f8b1d56ab97e4d6b1cca69'
name 'Google App Engine'
homepage 'https://developers.google.com/appengine/'
license :apache
app 'GoogleAppEngineLauncher.app'
end
| cask :v1 => 'googleappengine' do
version '1.9.28'
sha256 'bc63f29a0fab4521975107db66031bc9a60cb74f1c5c1b815febc89f3d690de9'
# googleapis.com is the official download host per the vendor homepage
url "https://storage.googleapis.com/appengine-sdks/featured/GoogleAppEngineLauncher-#{version}.dmg"
appcast 'https://storage.googleapis.com/appengine-sdks',
:sha256 => '4981d218798ee2a124921c980c8c8a71b3538ddeb6f8b1d56ab97e4d6b1cca69'
name 'Google App Engine'
homepage 'https://developers.google.com/appengine/'
license :apache
app 'GoogleAppEngineLauncher.app'
end
|
Fix php::fpm::config specs for php_settings | require 'spec_helper'
describe 'php::fpm::config' do
let(:facts) { { :osfamily => 'Debian' } }
context 'creates config file' do
let(:params) {{
:php_inifile => '/etc/php5/conf.d/unique-name.ini',
:php_config => {
'apc.enabled' => 1,
},
}}
it { should contain_class('php::fpm::config').with({
:php_inifile => '/etc/php5/conf.d/unique-name.ini',
:php_config => {
'apc.enabled' => 1,
},
})}
it { should contain_php__config('fpm').with({
:file => '/etc/php5/conf.d/unique-name.ini',
:config => {
'apc.enabled' => 1,
},
})}
end
end
| require 'spec_helper'
describe 'php::fpm::config' do
let(:facts) { { :osfamily => 'Debian' } }
context 'creates config file' do
let(:params) {{
:php_inifile => '/etc/php5/conf.d/unique-name.ini',
:php_settings => {
'apc.enabled' => 1,
},
}}
it { should contain_class('php::fpm::config').with({
:php_inifile => '/etc/php5/conf.d/unique-name.ini',
:php_settings => {
'apc.enabled' => 1,
},
})}
it { should contain_php__config('fpm').with({
:file => '/etc/php5/conf.d/unique-name.ini',
:config => {
'apc.enabled' => 1,
},
})}
end
end
|
Send params only for set environment variables. | def report_churn()
require File.join(File.dirname(__FILE__), '..', 'churn', 'churn_calculator')
Churn::ChurnCalculator.new({
:minimum_churn_count => ENV['CHURN_MINIMUM_CHURN_COUNT'],
:start_date => ENV['CHURN_START_DATE'],
:ignore_files => ENV['CHURN_IGNORE_FILES'],
}).report
end
desc "Report the current churn for the project"
task :churn do
report = report_churn()
puts report
end
| def report_churn()
require File.join(File.dirname(__FILE__), '..', 'churn', 'churn_calculator')
params = {}
{ :minimum_churn_count => ENV['CHURN_MINIMUM_CHURN_COUNT'],
:start_date => ENV['CHURN_START_DATE'],
:ignore_files => ENV['CHURN_IGNORE_FILES'],
}.each {|k,v| params[k] = v unless v.nil? }
Churn::ChurnCalculator.new(params).report
end
desc "Report the current churn for the project"
task :churn do
report = report_churn()
puts report
end
|
Improve mail method parentheses consistency. | class CollaboratorMailer < ActionMailer::Base
layout 'mailer'
#
# Creates an email to send to people when they have been added as
# a collaborator to a cookbook.
#
# @param cookbook_collaborator [CookbookCollaborator]
#
def added_email(cookbook_collaborator)
@cookbook = cookbook_collaborator.cookbook
user = cookbook_collaborator.user
@to = user.email
mail to: @to, subject: "You have been added as a collaborator to the #{@cookbook.name} cookbook!"
end
end
| class CollaboratorMailer < ActionMailer::Base
layout 'mailer'
#
# Creates an email to send to people when they have been added as
# a collaborator to a cookbook.
#
# @param cookbook_collaborator [CookbookCollaborator]
#
def added_email(cookbook_collaborator)
@cookbook = cookbook_collaborator.cookbook
user = cookbook_collaborator.user
@to = user.email
mail(to: @to, subject: "You have been added as a collaborator to the #{@cookbook.name} cookbook!")
end
end
|
Add Angry IP Scanner v3.2.2 | class AngryIpScanner < Cask
url 'http://github.com/angryziber/ipscan/releases/download/3.2.2/ipscan-mac-3.2.2.zip'
homepage 'http://angryip.org'
version '3.2.2'
sha256 'a9cb54d1e2377be31945692f6206a98056419b6ca641a3e79eada2a259e22226'
link 'Angry IP Scanner.app'
end
| |
Fix homepage to use SSL in Mendeley Cask | cask :v1 => 'mendeley-desktop' do
version '1.13.8'
sha256 'f90b5fec479b8dcb7bbf9d3dc6c4afa6a11d10636097653a28687c5f2415362a'
url "http://desktop-download.mendeley.com/download/Mendeley-Desktop-#{version}-OSX-Universal.dmg"
name 'Mendeley'
homepage 'http://www.mendeley.com/'
license :gratis
app 'Mendeley Desktop.app'
end
| cask :v1 => 'mendeley-desktop' do
version '1.13.8'
sha256 'f90b5fec479b8dcb7bbf9d3dc6c4afa6a11d10636097653a28687c5f2415362a'
url "http://desktop-download.mendeley.com/download/Mendeley-Desktop-#{version}-OSX-Universal.dmg"
name 'Mendeley'
homepage 'https://www.mendeley.com/'
license :gratis
app 'Mendeley Desktop.app'
end
|
Extend tests for pipeline status factory | require 'spec_helper'
describe Gitlab::Ci::Status::Pipeline::Factory do
subject do
described_class.new(pipeline)
end
context 'when pipeline has a core status' do
HasStatus::AVAILABLE_STATUSES.each do |core_status|
context "when core status is #{core_status}" do
let(:pipeline) do
create(:ci_pipeline, status: core_status)
end
it "fabricates a core status #{core_status}" do
expect(subject.fabricate!)
.to be_a Gitlab::Ci::Status.const_get(core_status.capitalize)
end
end
end
end
context 'when pipeline has warnings' do
let(:pipeline) do
create(:ci_pipeline, status: :success)
end
before do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline)
end
it 'fabricates extended "success with warnings" status' do
expect(subject.fabricate!)
.to be_a Gitlab::Ci::Status::Pipeline::SuccessWithWarnings
end
end
end
| require 'spec_helper'
describe Gitlab::Ci::Status::Pipeline::Factory do
subject do
described_class.new(pipeline)
end
let(:status) do
subject.fabricate!
end
context 'when pipeline has a core status' do
HasStatus::AVAILABLE_STATUSES.each do |core_status|
context "when core status is #{core_status}" do
let(:pipeline) do
create(:ci_pipeline, status: core_status)
end
it "fabricates a core status #{core_status}" do
expect(status).to be_a(
Gitlab::Ci::Status.const_get(core_status.capitalize))
end
it 'extends core status with common pipeline methods' do
expect(status).to have_details
expect(status.details_path).to include "pipelines/#{pipeline.id}"
end
end
end
end
context 'when pipeline has warnings' do
let(:pipeline) do
create(:ci_pipeline, status: :success)
end
before do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline)
end
it 'fabricates extended "success with warnings" status' do
expect(status)
.to be_a Gitlab::Ci::Status::Pipeline::SuccessWithWarnings
end
it 'extends core status with common pipeline methods' do
expect(status).to have_details
end
end
end
|
Clarify that acknowledged means 'not ignored' | module LicenseFinder
class DecisionApplier
def initialize(options)
@decisions = options.fetch(:decisions)
@packages = options.fetch(:packages)
end
def unapproved
acknowledged.reject(&:approved?)
end
def acknowledged
base_packages = decisions.packages + packages
base_packages.
reject { |package| ignored?(package) }.
map { |package| with_decided_licenses(package) }.
map { |package| with_approval(package) }
end
private
attr_reader :packages, :decisions
def ignored?(package)
decisions.ignored?(package.name) ||
package.groups.any? { |group| decisions.ignored_group?(group) }
end
def with_decided_licenses(package)
decisions.licenses_of(package.name).each do |license|
package.decide_on_license license
end
package
end
def with_approval(package)
if decisions.approved?(package.name)
package.approved_manually!(decisions.approval_of(package.name))
elsif package.licenses.any? { |license| decisions.whitelisted?(license) }
package.whitelisted!
end
package
end
end
end
| module LicenseFinder
class DecisionApplier
def initialize(options)
@decisions = options.fetch(:decisions)
@system_packages = options.fetch(:packages)
end
def unapproved
acknowledged.reject(&:approved?)
end
def acknowledged
packages.reject { |package| ignored?(package) }
end
private
attr_reader :system_packages, :decisions
def packages
result = decisions.packages + system_packages
result.
map { |package| with_decided_licenses(package) }.
map { |package| with_approval(package) }
end
def ignored?(package)
decisions.ignored?(package.name) ||
package.groups.any? { |group| decisions.ignored_group?(group) }
end
def with_decided_licenses(package)
decisions.licenses_of(package.name).each do |license|
package.decide_on_license license
end
package
end
def with_approval(package)
if decisions.approved?(package.name)
package.approved_manually!(decisions.approval_of(package.name))
elsif package.licenses.any? { |license| decisions.whitelisted?(license) }
package.whitelisted!
end
package
end
end
end
|
Add UTF-8 encoding to make ruby 1.9 happy | task :contributors do
contributors = `git log --pretty=short --no-merges | git shortlog -ne | egrep -ve '^ +' | egrep -ve '^$'`
puts contributors.split("\n").length
end
task :codeswarm do
sh "code_swarm --reload" rescue nil # Fails because of encoding - which we'll fix
sh "iconv -f latin1 -t utf-8 .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "sed -e 's/Aslak\ Hellesøy@.BEKK.no/aslak.hellesoy@gmail.com/g' .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "sed -e 's/josephwilk@joesniff.co.uk/joe@josephwilk.net/g' .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "code_swarm"
end | # encoding: utf-8
task :contributors do
contributors = `git log --pretty=short --no-merges | git shortlog -ne | egrep -ve '^ +' | egrep -ve '^$'`
puts contributors.split("\n").length
end
task :codeswarm do
sh "code_swarm --reload" rescue nil # Fails because of encoding - which we'll fix
sh "iconv -f latin1 -t utf-8 .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "sed -e 's/Aslak\ Hellesøy@.BEKK.no/aslak.hellesoy@gmail.com/g' .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "sed -e 's/josephwilk@joesniff.co.uk/joe@josephwilk.net/g' .git/.code_swarm/log.xml > tmp.xml && mv tmp.xml .git/.code_swarm/log.xml"
sh "code_swarm"
end
|
Replace missing with_tty guard (needs to be pushed to rubyspec). | require File.dirname(__FILE__) + '/../fixtures/classes'
describe :io_tty, :shared => true do
# Yeah, this will probably break.
it "returns true if this stream is a terminal device (TTY)" do
File.open('/dev/tty') {|f| f.send @method }.should == true
end
it "returns false if this stream is not a terminal device (TTY)" do
File.open(__FILE__) {|f| f.send @method }.should == false
end
it "raises IOError on closed stream" do
lambda { IOSpecs.closed_file.send @method }.should raise_error(IOError)
end
end
| require File.dirname(__FILE__) + '/../fixtures/classes'
describe :io_tty, :shared => true do
with_tty do
# Yeah, this will probably break.
it "returns true if this stream is a terminal device (TTY)" do
File.open('/dev/tty') {|f| f.send @method }.should == true
end
end
it "returns false if this stream is not a terminal device (TTY)" do
File.open(__FILE__) {|f| f.send @method }.should == false
end
it "raises IOError on closed stream" do
lambda { IOSpecs.closed_file.send @method }.should raise_error(IOError)
end
end
|
Use upstream gemspec file matcher | # coding: utf-8
Gem::Specification.new do |spec|
spec.name = "minima"
spec.version = "1.0.1"
spec.authors = ["Joel Glovier"]
spec.email = ["jglovier@github.com"]
spec.summary = %q{A beautiful, minimal theme for Jekyll. NOT DONE YET.}
spec.homepage = "https://github.com/jekyll/minima"
spec.license = "MIT"
spec.metadata["plugin_type"] = "theme"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(exe)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.add_development_dependency "jekyll", "~> 3.2"
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"
end
| # coding: utf-8
Gem::Specification.new do |spec|
spec.name = "minima"
spec.version = "1.0.1"
spec.authors = ["Joel Glovier"]
spec.email = ["jglovier@github.com"]
spec.summary = %q{A beautiful, minimal theme for Jekyll. NOT DONE YET.}
spec.homepage = "https://github.com/jekyll/minima"
spec.license = "MIT"
spec.metadata["plugin_type"] = "theme"
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{^(<%= theme_directories.join("|") %>|LICENSE|README)/i}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.add_development_dependency "jekyll", "~> 3.2"
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"
end
|
Fix homepage and appcast to use SSL in iExplorer Cask | cask :v1 => 'iexplorer' do
version '3.7.4.0'
sha256 'd55e905def1a0b691fefdcf3ae2b0d3771b6a640f17b5168dac7f625d904e08c'
url "http://cdn.macroplant.com/release/iExplorer-#{version}.dmg"
appcast 'http://www.macroplant.com/iexplorer/ie3-appcast.xml',
:sha256 => '7d204dc3e1c42c6f50e30f1175c859b515f708d86a406f040ed684e2a5fda59c'
name 'iExplorer'
homepage 'http://www.macroplant.com/iexplorer/'
license :freemium
app 'iExplorer.app'
end
| cask :v1 => 'iexplorer' do
version '3.7.4.0'
sha256 'd55e905def1a0b691fefdcf3ae2b0d3771b6a640f17b5168dac7f625d904e08c'
url "http://cdn.macroplant.com/release/iExplorer-#{version}.dmg"
appcast 'https://www.macroplant.com/iexplorer/ie3-appcast.xml',
:sha256 => '7d204dc3e1c42c6f50e30f1175c859b515f708d86a406f040ed684e2a5fda59c'
name 'iExplorer'
homepage 'https://www.macroplant.com/iexplorer/'
license :freemium
app 'iExplorer.app'
end
|
Drop the index only for postgresql, because | class AddIndexToProjectAuthorizations < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index(:project_authorizations, :project_id)
end
def down
remove_index(:project_authorizations, :project_id)
end
end
| class AddIndexToProjectAuthorizations < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index(:project_authorizations, :project_id)
end
def down
remove_index(:project_authorizations, :project_id) if
Gitlab::Database.postgresql?
end
end
|
Rename private method `where` to avoid conflicts | require 'yt/actions/list'
require 'yt/models/request'
module Yt
module Actions
module DeleteAll
include List
private
def do_delete_all(params = {})
where(params).map do |item|
item.delete
end.tap { @items = [] }
end
def where(params = {})
list.find_all do |item|
params.all? do |method, value|
# TODO: could be symbol etc...
item.respond_to?(method) && case value
when Regexp then item.send(method) =~ value
else item.send(method) == value
end
end
end
end
end
end
end | require 'yt/actions/list'
require 'yt/models/request'
module Yt
module Actions
module DeleteAll
include List
private
def do_delete_all(params = {})
list_all(params).map do |item|
item.delete
end.tap { @items = [] }
end
def list_all(params = {})
list.find_all do |item|
params.all? do |method, value|
# TODO: could be symbol etc...
item.respond_to?(method) && case value
when Regexp then item.send(method) =~ value
else item.send(method) == value
end
end
end
end
end
end
end |
Remove Chef 11 compat code from the chef_gem installs | #
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook Name:: windows
# Recipe:: default
#
# Copyright:: 2011-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# gems with precompiled binaries
%w( win32-api win32-service ).each do |win_gem|
chef_gem win_gem do
options '--platform=mswin32'
action :install
compile_time false if respond_to?(:compile_time)
end
end
# the rest
%w( windows-api windows-pr win32-dir win32-event win32-mutex ).each do |win_gem|
chef_gem win_gem do
action :install
compile_time false if respond_to?(:compile_time)
end
end
| #
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook Name:: windows
# Recipe:: default
#
# Copyright:: 2011-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# gems with precompiled binaries
%w( win32-api win32-service ).each do |win_gem|
chef_gem win_gem do
options '--platform=mswin32'
action :install
compile_time false
end
end
# the rest
%w( windows-api windows-pr win32-dir win32-event win32-mutex ).each do |win_gem|
chef_gem win_gem do
action :install
compile_time false
end
end
|
Add new external command: unpack | require 'formula'
module Homebrew extend self
def unpack
unpack_usage = <<-EOS
Usage: brew unpack [--destdir=path/to/extract/in] <formulae ...>
Unpack formulae source code for inspection.
Formulae archives will be extracted to subfolders inside the current working
directory or a directory specified by `--destdir`.
EOS
if ARGV.empty?
puts unpack_usage
exit 0
end
formulae = ARGV.named
raise FormulaUnspecifiedError if formulae.empty?
unpack_dir = ARGV.options_only.select {|o| o.start_with? "--destdir="}
if unpack_dir.empty?
unpack_dir = Pathname.new Dir.getwd
else
unpack_dir = Pathname.new(unpack_dir.first.split('=')[1]).realpath
unpack_dir.mkpath unless unpack_dir.exist?
end
raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable?
formulae.each do |f|
f = Formula.factory(f)
unless f.downloader.kind_of? CurlDownloadStrategy
stage_dir = unpack_dir + [f.name, f.version].join('-')
stage_dir.mkpath unless stage_dir.exist?
else
stage_dir = unpack_dir
end
# Can't use a do block here without DownloadStrategy do blocks throwing:
# warning: conflicting chdir during another chdir block
Dir.chdir stage_dir
f.downloader.fetch
f.downloader.stage
Dir.chdir unpack_dir
end
end
end
# Here is the actual code that gets run when `brew` loads this external
# command.
Homebrew.unpack
| |
Replace any absolute paths in output with a relative one. | require "aruba" | require "aruba"
AfterStep do
@last_stderr.gsub!(/#{Dir.pwd}\/tmp\/aruba/, '.') if @last_stderr
@last_stdout.gsub!(/#{Dir.pwd}\/tmp\/aruba/, '.') if @last_stdout
end |
Remove feature flag for FindAllRemoteBranches | module Gitlab
module Git
module RepositoryMirroring
def remote_branches(remote_name)
gitaly_migrate(:ref_find_all_remote_branches) do |is_enabled|
if is_enabled
gitaly_ref_client.remote_branches(remote_name)
else
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
rugged_remote_branches(remote_name)
end
end
end
end
private
def rugged_remote_branches(remote_name)
branches = []
rugged.references.each("refs/remotes/#{remote_name}/*").map do |ref|
name = ref.name.sub(%r{\Arefs/remotes/#{remote_name}/}, '')
begin
target_commit = Gitlab::Git::Commit.find(self, ref.target.oid)
branches << Gitlab::Git::Branch.new(self, name, ref.target, target_commit)
rescue Rugged::ReferenceError
# Omit invalid branch
end
end
branches
end
end
end
end
| module Gitlab
module Git
module RepositoryMirroring
def remote_branches(remote_name)
gitaly_ref_client.remote_branches(remote_name)
end
end
end
end
|
Clear the template cache in development | require "action_view"
module HamlCoffeeAssets
module ActionView
# Custom resolver to prevent Haml Coffee templates from being rendered by
# Rails for non-HTML formats, since a template name without a MIME type
# in it would normally be a fallback for all formats.
#
class Resolver < ::ActionView::FileSystemResolver
def find_templates(name, prefix, partial, details)
if details[:formats].include?(:html)
super
else
[]
end
end
end
end
end
| require "action_view"
module HamlCoffeeAssets
module ActionView
# Custom resolver to prevent Haml Coffee templates from being rendered by
# Rails for non-HTML formats, since a template name without a MIME type
# in it would normally be a fallback for all formats.
#
class Resolver < ::ActionView::FileSystemResolver
def find_templates(name, prefix, partial, details)
if details[:formats].include?(:html)
clear_cache if ::Rails.env == "development"
super
else
[]
end
end
end
end
end
|
Add support for Mention app | class Mention < Cask
version :latest
sha256 :no_check
url 'https://en.mention.com/downloads/mac/mention.dmg'
homepage 'https://en.mention.com/'
app 'Mention.app'
end
| |
Use built in validation on AboutMeValidator model | # -*- encoding : utf-8 -*-
# models/about_me_validator.rb:
# Validates editing about me text on user profile pages.
#
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AboutMeValidator
include ActiveModel::Validations
attr_accessor :about_me
# TODO: Switch to built in validations
validate :length_of_about_me
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
private
def length_of_about_me
if !about_me.blank? && about_me.size > 500
errors.add(:about_me, _("Please keep it shorter than 500 characters"))
end
end
end
| # -*- encoding : utf-8 -*-
# models/about_me_validator.rb:
# Validates editing about me text on user profile pages.
#
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
class AboutMeValidator
include ActiveModel::Validations
attr_accessor :about_me
validates_length_of :about_me, maximum: 500, message: _("Please keep it shorter than 500 characters")
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
end
|
Add version limit to omniauth-oauth2 gem | Gem::Specification.new do |gem|
gem.name = 'omniauth-beeminder'
gem.authors = ["Andy Brett"]
gem.license = 'MIT'
gem.description = %q{An omniauth strategy for Beeminder.}
gem.email = ['andy@andybrett.com']
gem.files = ['lib/omniauth-beeminder.rb', 'lib/omniauth/strategies/beeminder.rb', 'lib/omniauth-beeminder/version.rb']
gem.homepage = 'https://github.com/beeminder/omniauth-beeminder'
gem.require_paths = ['lib']
gem.summary = %q{Omniauth strategy for Beeminder}
gem.add_dependency 'omniauth-oauth2', '>= 1.1.1'
gem.version = "0.1.0"
end | Gem::Specification.new do |gem|
gem.name = 'omniauth-beeminder'
gem.authors = ["Andy Brett"]
gem.license = 'MIT'
gem.description = %q{An omniauth strategy for Beeminder.}
gem.email = ['andy@andybrett.com']
gem.files = ['lib/omniauth-beeminder.rb', 'lib/omniauth/strategies/beeminder.rb', 'lib/omniauth-beeminder/version.rb']
gem.homepage = 'https://github.com/beeminder/omniauth-beeminder'
gem.require_paths = ['lib']
gem.summary = %q{Omniauth strategy for Beeminder}
gem.add_dependency 'omniauth-oauth2', ['>= 1.1.1','< 1.4.0']
gem.version = "0.1.1"
end
|
Call the correct method in the BlocksJsonSerialization spec | require 'rails_helper'
describe BlocksJsonSerialization do
DummyModel = Class.new do
include BlocksJsonSerialization
end
it 'blocks as_json' do
expect { DummyModel.new.to_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
it 'blocks to_json' do
expect { DummyModel.new.to_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
end
| require 'rails_helper'
describe BlocksJsonSerialization do
DummyModel = Class.new do
include BlocksJsonSerialization
end
it 'blocks as_json' do
expect { DummyModel.new.as_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
it 'blocks to_json' do
expect { DummyModel.new.to_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
end
|
Update Gearmand to version 0.15 | require 'formula'
class Gearman <Formula
url 'http://launchpad.net/gearmand/trunk/0.12/+download/gearmand-0.12.tar.gz'
homepage 'http://gearman.org/'
md5 '6e88a6bfb26e50d5aed37d143184e7f2'
depends_on 'libevent'
def install
system "./configure", "--prefix=#{prefix}"
system "make install"
end
end
| require 'formula'
class Gearman <Formula
url 'http://launchpad.net/gearmand/trunk/0.15/+download/gearmand-0.15.tar.gz'
homepage 'http://gearman.org/'
md5 'd394214d3cddc5af237d73befc7e3999'
depends_on 'libevent'
def install
system "./configure", "--prefix=#{prefix}"
system "make install"
end
end
|
Clean up documentation and a typo | module Rake
# The NameSpace class will lookup task names in the the scope
# defined by a +namespace+ command.
#
class NameSpace
# Create a namespace lookup object using the given task manager
# and the list of scopes.
def initialize(task_manager, scope_list)
@task_manager = task_manager
@scope = scope_list.dup
end
# Lookup a task named +name+ in the namespace.
def [](name)
@task_manager.lookup(name, @scope)
end
##
# The scope of the namespace (a LinkedList)
def scope
@scope.dup
end
# Return the list of tasks defined in this and nested namespaces.
def tasks
@task_manager.tasks_in_scope(@scope)
end
end
end
| module Rake
##
# The NameSpace class will lookup task names in the scope defined by a
# +namespace+ command.
class NameSpace
##
# Create a namespace lookup object using the given task manager
# and the list of scopes.
def initialize(task_manager, scope_list)
@task_manager = task_manager
@scope = scope_list.dup
end
##
# Lookup a task named +name+ in the namespace.
def [](name)
@task_manager.lookup(name, @scope)
end
##
# The scope of the namespace (a LinkedList)
def scope
@scope.dup
end
##
# Return the list of tasks defined in this and nested namespaces.
def tasks
@task_manager.tasks_in_scope(@scope)
end
end
end
|
Add support for new Installshield versions | require 'formula'
class Unshield < Formula
homepage 'http://www.synce.org/oldwiki/index.php/Unshield'
url 'http://downloads.sourceforge.net/project/synce/Unshield/0.6/unshield-0.6.tar.gz'
sha1 '3e1197116145405f786709608a5a636a19f4f3e1'
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
end
| require 'formula'
class Unshield < Formula
homepage 'http://www.synce.org/oldwiki/index.php/Unshield'
url 'http://downloads.sourceforge.net/project/synce/Unshield/0.6/unshield-0.6.tar.gz'
sha1 '3e1197116145405f786709608a5a636a19f4f3e1'
# Add support for new Installshield versions. See:
# http://sourceforge.net/tracker/?func=detail&aid=3163039&group_id=30550&atid=399603
def patches
"http://patch-tracker.debian.org/patch/series/dl/unshield/0.6-3/new_installshield_format.patch"
end
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
end
|
Fix path for gembins in specs | module Spec
module Rubygems
def self.setup
Gem.clear_paths
ENV['BUNDLE_PATH'] = nil
ENV['GEM_HOME'] = ENV['GEM_PATH'] = Path.base_system_gems.to_s
ENV['PATH'] = "#{Path.home}/.bundler/bin:#{Path.system_gem_path}/bin:#{ENV['PATH']}"
unless File.exist?("#{Path.base_system_gems}")
FileUtils.mkdir_p(Path.base_system_gems)
puts "running `gem install builder rake fakeweb --no-rdoc --no-ri`"
`gem install builder rake fakeweb --no-rdoc --no-ri`
end
ENV['HOME'] = Path.home.to_s
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end
def gem_command(command, args = "", options = {})
if command == :exec && !options[:no_quote]
args = args.gsub(/(?=")/, "\\")
args = %["#{args}"]
end
lib = File.join(File.dirname(__FILE__), '..', '..', 'lib')
%x{#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}}.strip
end
end
end | module Spec
module Rubygems
def self.setup
Gem.clear_paths
ENV['BUNDLE_PATH'] = nil
ENV['GEM_HOME'] = ENV['GEM_PATH'] = Path.base_system_gems.to_s
ENV['PATH'] = "#{Path.home}/.bundle/bin:#{Path.system_gem_path}/bin:#{ENV['PATH']}"
unless File.exist?("#{Path.base_system_gems}")
FileUtils.mkdir_p(Path.base_system_gems)
puts "running `gem install builder rake fakeweb --no-rdoc --no-ri`"
`gem install builder rake fakeweb --no-rdoc --no-ri`
end
ENV['HOME'] = Path.home.to_s
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
end
def gem_command(command, args = "", options = {})
if command == :exec && !options[:no_quote]
args = args.gsub(/(?=")/, "\\")
args = %["#{args}"]
end
lib = File.join(File.dirname(__FILE__), '..', '..', 'lib')
%x{#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}}.strip
end
end
end |
Add a task to enable ezine members state | class SS::Migration20150408081234
def change
Ezine::Member.where(state: nil).each do |member|
member.update state: 'enabled'
end
end
end
| |
Fix object_attributes() ( i.e., was calling join within the block not on it ) | module Fog
# Fog::Formatador
class Formatador
attr_accessor :object, :thread, :string
def initialize(obj, t)
raise ArgumentError, "#{t} is not a Thread" unless t.is_a? Thread
@object, @thread = obj, t
thread[:formatador] ||= ::Formatador.new
end
def to_s
return string unless string.nil?
init_string
indent { string << object_string }
(string << "#{indentation}>").dup
end
private
def indent(&block)
thread[:formatador].indent &block
end
def indentation
thread[:formatador].indentation
end
def init_string
@string = "#{indentation}<#{object.class.name}\n"
end
def object_string
"#{attribute_string}#{indentation}[#{nested_objects_string}"
end
def attribute_string
if object.attributes.empty?
"#{indentation}#{object_attributes}\n"
else
""
end
end
def nested_objects_string
if object.empty?
"\n#{inspect_nested}\n"
else
""
end
end
def object_attributes
object.class.attributes.map do |attr|
"#{attr}=#{send(attr).inspect}".join(",\n#{indentation}")
end
end
def inspect_nested
nested = ""
indent { nested << object.map(&:inspect).join(", \n") && nested << "\n" }
nested << indentation
nested
end
end
end
| module Fog
# Fog::Formatador
class Formatador
attr_accessor :object, :thread, :string
def initialize(obj, t)
raise ArgumentError, "#{t} is not a Thread" unless t.is_a? Thread
@object, @thread = obj, t
thread[:formatador] ||= ::Formatador.new
end
def to_s
return string unless string.nil?
init_string
indent { string << object_string }
(string << "#{indentation}>").dup
end
private
def indent(&block)
thread[:formatador].indent &block
end
def indentation
thread[:formatador].indentation
end
def init_string
@string = "#{indentation}<#{object.class.name}\n"
end
def object_string
"#{attribute_string}#{indentation}[#{nested_objects_string}"
end
def attribute_string
if object.attributes.empty?
"#{indentation}#{object_attributes}\n"
else
""
end
end
def nested_objects_string
if object.empty?
"\n#{inspect_nested}\n"
else
""
end
end
def object_attributes
attrs = object.class.attributes.map do |attr|
"#{attr}=#{object.send(attr).inspect}"
end
attrs.join(",\n#{indentation}")
end
def inspect_nested
nested = ""
indent { nested << object.map(&:inspect).join(", \n") && nested << "\n" }
nested << indentation
nested
end
end
end
|
Fix reporting :create to trogdir on update | module Workers
class UpdateGoogleAppsAccount
include Sidekiq::Worker
sidekiq_options retry: false
def perform(email, first_name, last_name, department, title, privacy, sync_log_id)
begin
if GoogleAccount.new(email).update!(first_name, last_name, department, title, privacy)
TrogdirChangeFinishWorker.perform_async sync_log_id, :create
end
rescue StandardError => err
TrogdirChangeErrorWorker.perform_async sync_log_id, err.message
Raven.capture_exception(err) if defined? Raven
end
end
end
end
| module Workers
class UpdateGoogleAppsAccount
include Sidekiq::Worker
sidekiq_options retry: false
def perform(email, first_name, last_name, department, title, privacy, sync_log_id)
begin
if GoogleAccount.new(email).update!(first_name, last_name, department, title, privacy)
TrogdirChangeFinishWorker.perform_async sync_log_id, :update
end
rescue StandardError => err
TrogdirChangeErrorWorker.perform_async sync_log_id, err.message
Raven.capture_exception(err) if defined? Raven
end
end
end
end
|
Upgrade Bitwig Studio to 1.3.3 | cask :v1 => 'bitwig-studio' do
version '1.1.8'
sha256 '9500a6479055402febb12817c26af187706d2937a1c781c1a0147493ffdd7775'
url "https://downloads.bitwig.com/Bitwig%20Studio%20#{version}.dmg"
name 'Bitwig Studio'
homepage 'https://www.bitwig.com'
license :commercial
app 'Bitwig Studio.app'
end
| cask :v1 => 'bitwig-studio' do
version '1.3.3'
sha256 '6d614095b1b39e387ed4c96a70342c5d982a6d4a5c71e6a4498f25b7898b909b'
url "https://downloads.bitwig.com/Bitwig%20Studio%20#{version}.dmg"
name 'Bitwig Studio'
homepage 'https://www.bitwig.com'
license :commercial
app 'Bitwig Studio.app'
end
|
Fix failing migration for new price and currency columns of ticket | class SplitTicketPriceInPriceAndCurrency < ActiveRecord::Migration
class TempTicket < ActiveRecord::Base
self.table_name = 'tickets'
attr_accessible :ticket_price, :price_cents, :price_currency
end
def change
add_money :tickets, :price
TempTicket.all.each do |ticket|
# Replace currency symbol with ISO Code
ticket.ticket_price.gsub!('€', 'EUR')
ticket.ticket_price.gsub!('$', 'USD')
ticket.ticket_price.gsub!('£', 'GBP')
ticket.ticket_price.gsub!('¥', 'CNY')
ticket.ticket_price.gsub!('₹', 'INR')
money = ticket.ticket_price.to_money
ticket.price_cents = money.cents
ticket.price_currency = money.currency_as_string
ticket.save
end
remove_column :tickets, :ticket_price
remove_column :tickets, :url
end
end
| class SplitTicketPriceInPriceAndCurrency < ActiveRecord::Migration
class TempTicket < ActiveRecord::Base
self.table_name = 'tickets'
attr_accessible :ticket_price, :price_cents, :price_currency
end
def change
add_money :tickets, :price
TempTicket.all.each do |ticket|
# Replace currency symbol with ISO Code
if ticket.ticket_price
ticket.ticket_price.gsub!('€', 'EUR')
ticket.ticket_price.gsub!('$', 'USD')
ticket.ticket_price.gsub!('£', 'GBP')
ticket.ticket_price.gsub!('¥', 'CNY')
ticket.ticket_price.gsub!('₹', 'INR')
money = ticket.ticket_price.to_money
ticket.price_cents = money.cents
ticket.price_currency = money.currency_as_string
ticket.save
end
end
remove_column :tickets, :ticket_price
remove_column :tickets, :url
end
end
|
Reduce expected rate of date parses for now | require "test_utils"
require "logstash/filters/date"
describe LogStash::Filters::Date do
extend LogStash::RSpec
describe "performance test of java syntax parsing" do
event_count = 100000
min_rate = 10000
max_duration = event_count / min_rate
input = "Nov 24 01:29:01 -0800"
config <<-CONFIG
input {
generator {
add_field => ["mydate", "#{input}"]
count => #{event_count}
type => "generator"
}
}
filter {
date {
mydate => "MMM dd HH:mm:ss Z"
}
}
output { null { } }
CONFIG
agent do
puts "date parse rate: #{event_count / @duration}"
insist { @duration } < max_duration
end
end
end
| require "test_utils"
require "logstash/filters/date"
describe LogStash::Filters::Date do
extend LogStash::RSpec
describe "performance test of java syntax parsing" do
event_count = 100000
min_rate = 5000
max_duration = event_count / min_rate
input = "Nov 24 01:29:01 -0800"
config <<-CONFIG
input {
generator {
add_field => ["mydate", "#{input}"]
count => #{event_count}
type => "generator"
}
}
filter {
date {
mydate => "MMM dd HH:mm:ss Z"
}
}
output { null { } }
CONFIG
agent do
puts "date parse rate: #{event_count / @duration}"
insist { @duration } < max_duration
end
end
end
|
Add runtime dependency to gemspec | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mina/slack/version'
Gem::Specification.new do |spec|
spec.name = "mina-slack"
spec.version = Mina::Slack::VERSION
spec.authors = ["TAKAyuki_atkwsk"]
spec.email = ["takagi.takayuki.yuuki@gmail.com"]
spec.description = %q{TODO: Write a gem description}
spec.summary = %q{TODO: Write a gem summary}
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
end
| # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mina/slack/version'
Gem::Specification.new do |spec|
spec.name = "mina-slack"
spec.version = Mina::Slack::VERSION
spec.authors = ["TAKAyuki_atkwsk"]
spec.email = ["takagi.takayuki.yuuki@gmail.com"]
spec.description = %q{Slack web hook from mina}
spec.summary = %q{Slack web hook from mina}
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_runtime_dependency 'rest-client', '~> 1.6.7'
spec.add_runtime_dependency 'mina', '~> 0.3.0'
end
|
Clarify tests around track! helper in non-controller contexts. | require "test_helper"
describe Object do
describe "#track!" do
it "identity option sets identity" do
metric "Coolness"
new_ab_test :foobar do
alternatives "foo", "bar"
metrics :coolness
end
track! :coolness, :identity=>'quux', :values=>[2]
# experiment(:foobar).alternatives.sum(&:conversions).must_equal 2
assert_equal 2, experiment(:foobar).alternatives.sum(&:conversions)
end
end
end | require "test_helper"
describe Object do
describe "#track!" do
it "identity option sets identity" do
metric "Coolness"
new_ab_test :foobar do
alternatives "foo", "bar"
metrics :coolness
end
track!(:coolness, :identity=>'quux')
assert_equal 1, experiment(:foobar).alternatives.sum(&:conversions)
end
it "accepts value for conversion" do
metric "Coolness"
new_ab_test :foobar do
alternatives "foo", "bar"
metrics :coolness
end
track!(:coolness, :identity=>'quux', :values=>[2])
assert_equal 2, experiment(:foobar).alternatives.sum(&:conversions)
end
end
end
|
Set default codec to 'line' as this keeps old backwards-compatible behavior | require "logstash/outputs/base"
require "logstash/namespace"
class LogStash::Outputs::Stdout < LogStash::Outputs::Base
begin
require "ap"
rescue LoadError
end
config_name "stdout"
milestone 3
# Enable debugging. Tries to pretty-print the entire event object.
config :debug, :validate => :boolean, :default => false
# Debug output format: ruby (default), json
config :debug_format, :default => "ruby", :validate => ["ruby", "dots"]
# The message to emit to stdout.
config :message, :validate => :string, :default => "%{+yyyy-MM-dd'T'HH:mm:ss.SSSZ} %{host}: %{message}"
public
def register
@print_method = method(:ap) rescue method(:p)
@codec.on_event do |event|
$stdout.write(event)
end
end
def receive(event)
return unless output?(event)
if event == LogStash::SHUTDOWN
finished
return
end
@codec.encode(event)
end
end # class LogStash::Outputs::Stdout
| require "logstash/outputs/base"
require "logstash/namespace"
class LogStash::Outputs::Stdout < LogStash::Outputs::Base
begin
require "ap"
rescue LoadError
end
config_name "stdout"
milestone 3
default :codec, "line"
# Enable debugging. Tries to pretty-print the entire event object.
config :debug, :validate => :boolean, :default => false
# Debug output format: ruby (default), json
config :debug_format, :default => "ruby", :validate => ["ruby", "dots"]
# The message to emit to stdout.
config :message, :validate => :string, :default => "%{+yyyy-MM-dd'T'HH:mm:ss.SSSZ} %{host}: %{message}"
public
def register
@print_method = method(:ap) rescue method(:p)
@codec.on_event do |event|
$stdout.write(event)
end
end
def receive(event)
return unless output?(event)
if event == LogStash::SHUTDOWN
finished
return
end
@codec.encode(event)
end
end # class LogStash::Outputs::Stdout
|
Write basic tests for Bucket | require 'discordrb'
# alias so I don't have to type it out every time...
BUCKET = Discordrb::Commands::Bucket
RATELIMITER = Discordrb::Commands::RateLimiter
describe Discordrb::Commands::Bucket do
describe 'rate_limited?' do
it 'should not rate limit one request' do
BUCKET.new(1, 5, 2).rate_limited?(:a).should be_falsy
BUCKET.new(nil, nil, 2).rate_limited?(:a).should be_falsy
BUCKET.new(1, 5, nil).rate_limited?(:a).should be_falsy
BUCKET.new(0, 1, nil).rate_limited?(:a).should be_falsy
BUCKET.new(0, 1_000_000_000, 500_000_000).rate_limited?(:a).should be_falsy
end
it 'should fail to initialize with invalid arguments' do
expect { BUCKET.new(0, nil, 0) }.to raise_error(ArgumentError)
end
it 'should fail to rate limit something invalid' do
expect { BUCKET.new(1, 5, 2).rate_limited("can't RL a string!") }.to raise_error(ArgumentError)
end
end
end | |
Modify has_many :responses in Post model to return responses ordered by created_at in descending order | class Post < ActiveRecord::Base
validates :title, :body, :user_id, presence: true
belongs_to :user
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
has_many :responses, dependent: :destroy
has_many :likes, as: :likeable
has_many :likers, through: :likes, source: :user
has_many :bookmarks, as: :bookmarkable
has_many :bookmarkers, through: :bookmarks, source: :user
delegate :username, to: :user
default_scope { order(created_at: :desc) }
scope :latest, ->(number) { order(created_at: :desc).limit(number) }
scope :top_stories, ->(number) { order(:likes_count).limit(number) }
mount_uploader :picture, PictureUploader
def self.tagged_with(name)
Tag.find_by!(name: name).posts
end
def all_tags=(names)
self.tags = names.split(",").map do |name|
Tag.where(name: name.strip).first_or_create!
end
end
def all_tags
tags.map(&:name).join(", ")
end
end
| class Post < ActiveRecord::Base
validates :title, :body, :user_id, presence: true
belongs_to :user
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings
has_many :responses, -> { order(created_at: :desc) }, dependent: :destroy
has_many :likes, as: :likeable
has_many :likers, through: :likes, source: :user
has_many :bookmarks, as: :bookmarkable
has_many :bookmarkers, through: :bookmarks, source: :user
delegate :username, to: :user
default_scope { order(created_at: :desc) }
scope :latest, ->(number) { order(created_at: :desc).limit(number) }
scope :top_stories, ->(number) { order(:likes_count).limit(number) }
mount_uploader :picture, PictureUploader
def self.tagged_with(name)
Tag.find_by!(name: name).posts
end
def all_tags=(names)
self.tags = names.split(",").map do |name|
Tag.where(name: name.strip).first_or_create!
end
end
def all_tags
tags.map(&:name).join(", ")
end
end
|
Upgrade Opera Beta.app to 28.0.1750.36 | cask :v1 => 'opera-beta' do
version '27.0.1689.44'
sha256 'a07580830e9b772ef6644d34c84b260fb17ea592f50b6d4a36fa3ffa6bdc4b0b'
url "http://get.geo.opera.com/pub/opera-beta/#{version}/mac/Opera_beta_#{version}_Setup.dmg"
homepage 'http://www.opera.com/computer/beta'
license :unknown
app 'Opera Beta.app'
end
| cask :v1 => 'opera-beta' do
version '28.0.1750.36'
sha256 'cab81fd4bee7b73ab8b377db3e73305f8dde64c2a495f4aa1acfd742e0ba248b'
url "http://get.geo.opera.com/pub/opera-beta/#{version}/mac/Opera_beta_#{version}_Setup.dmg"
homepage 'http://www.opera.com/computer/beta'
license :unknown
app 'Opera Beta.app'
end
|
Fix mock returning a hash instead of an array | module Fog
module Identity
class OpenStack
class Real
def list_roles_for_user_on_tenant(tenant_id, user_id)
request(
:expects => [200],
:method => 'GET',
:path => "tenants/#{tenant_id}/users/#{user_id}/roles"
)
end # def list_roles_for_user_on_tenant
end # class Real
class Mock
def list_roles_for_user_on_tenant(tenant_id, user_id)
Excon::Response.new(
:body => { 'roles' => self.data[:roles] },
:status => 200
)
end # def list_roles_for_user_on_tenant
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog
| module Fog
module Identity
class OpenStack
class Real
def list_roles_for_user_on_tenant(tenant_id, user_id)
request(
:expects => [200],
:method => 'GET',
:path => "tenants/#{tenant_id}/users/#{user_id}/roles"
)
end # def list_roles_for_user_on_tenant
end # class Real
class Mock
def list_roles_for_user_on_tenant(tenant_id, user_id)
Excon::Response.new(
:body => { 'roles' => self.data[:roles].values },
:status => 200
)
end # def list_roles_for_user_on_tenant
end # class Mock
end # class OpenStack
end # module Identity
end # module Fog
|
Fix for '"status_code"=>210, "status_message"=>"No notifications"' error | require 'httparty'
require 'json'
require 'pushwoosh/request'
require 'pushwoosh/response'
require 'active_support/core_ext/hash/indifferent_access'
require 'pushwoosh/helpers'
module Pushwoosh
class PushNotification
class Error < StandardError; end;
STRING_BYTE_LIMIT = 256
def initialize(options = {})
fail 'Missing application' unless options[:application]
fail 'Missing auth key' unless options[:auth]
@base_request = {
request: {
application: options[:application],
auth: options[:auth]
}
}
end
def notify_all(message, options= {})
options.merge!(content: Helpers.limit_string(message, STRING_BYTE_LIMIT))
create_message(options)
end
def notify_devices(message, devices, options = {})
create_message(
content: Helpers.limit_string(message, STRING_BYTE_LIMIT),
devices: devices
)
end
private
def create_message(notification_options = {})
fail Error, 'Message is missing' if notification_options[:content].empty?
response = Request.post("/createMessage",
body: build_request(notification_options).to_json)
Response.new(response.parsed_response.with_indifferent_access)
end
def build_request(notification_options = {})
@base_request.merge(notifications:
[default_notification_options.merge(notification_options)])
end
def default_notification_options
{
send_date: "now",
ios_bagdes: "+1"
}
end
end
end
| require 'httparty'
require 'json'
require 'pushwoosh/request'
require 'pushwoosh/response'
require 'active_support/core_ext/hash/indifferent_access'
require 'pushwoosh/helpers'
module Pushwoosh
class PushNotification
class Error < StandardError; end;
STRING_BYTE_LIMIT = 256
def initialize(options = {})
fail 'Missing application' unless options[:application]
fail 'Missing auth key' unless options[:auth]
@base_request = {
request: {
application: options[:application],
auth: options[:auth]
}
}
end
def notify_all(message, options= {})
options.merge!(content: Helpers.limit_string(message, STRING_BYTE_LIMIT))
create_message(options)
end
def notify_devices(message, devices, options = {})
create_message(
content: Helpers.limit_string(message, STRING_BYTE_LIMIT),
devices: devices
)
end
private
def create_message(notification_options = {})
fail Error, 'Message is missing' if notification_options[:content].empty?
response = Request.post("/createMessage",
body: build_request(notification_options).to_json)
Response.new(response.parsed_response.with_indifferent_access)
end
def build_request(notification_options = {})
{
request: @base_request[:request].merge(notifications:
[default_notification_options.merge(notification_options)])
}
end
def default_notification_options
{
send_date: "now",
ios_bagdes: "+1"
}
end
end
end
|
Add spec for url_encode on date | require 'spec_helper'
describe Twilio::Util do
include Twilio::Util
it 'should parse a Date object' do
today = Time.now
url = url_encode({'DateSent>' => today})
url.should == "DateSent%3E=#{today.strftime('%Y-%m-%d')}"
end
end
| |
Upgrade Alfred 2.app to v2.5_299 | class Alfred < Cask
version '2.4_279'
sha256 '5faaa5e7029adb6a884433c3c442440cee6398241bc8098f02186e5e1f010dea'
url "https://cachefly.alfredapp.com/Alfred_#{version}.zip"
homepage 'http://www.alfredapp.com/'
license :commercial
app 'Alfred 2.app'
app 'Alfred 2.app/Contents/Preferences/Alfred Preferences.app'
postflight do
# Don't ask to move the app bundle to /Applications
system '/usr/bin/defaults', 'write', 'com.runningwithcrayons.alfred-2', 'suppressMoveToApplications', '-bool', 'true'
end
end
| class Alfred < Cask
version '2.5_299'
sha256 '4654da77e195342285b57253d1177f94e68adb8be8d7b10bd05d26353f75ecf6'
url "https://cachefly.alfredapp.com/Alfred_#{version}.zip"
homepage 'http://www.alfredapp.com/'
license :commercial
app 'Alfred 2.app'
app 'Alfred 2.app/Contents/Preferences/Alfred Preferences.app'
postflight do
# Don't ask to move the app bundle to /Applications
system '/usr/bin/defaults', 'write', 'com.runningwithcrayons.alfred-2', 'suppressMoveToApplications', '-bool', 'true'
end
end
|
Fix quotes in pushwoosh spec | require 'spec_helper'
describe Pushwoosh do
before do
Pushwoosh.configure do |config|
config.application = '5555-5555'
config.auth = 'abcefg'
end
end
describe '.notify_all' do
context 'when has message' do
it "sends push message" do
VCR.use_cassette 'pushwoosh/push_notification' do
response = described_class.notify_all("Testing")
expect(response.status_code).to eq 200
end
end
end
context 'when message is empty' do
it 'raises a error if message is empty' do
VCR.use_cassette 'pushwoosh/empty_message_push' do
expect { described_class.notify_all("") }.to raise_error
end
end
end
end
end
| require 'spec_helper'
describe Pushwoosh do
before do
Pushwoosh.configure do |config|
config.application = '5555-5555'
config.auth = 'abcefg'
end
end
describe '.notify_all' do
context 'when has message' do
it 'sends push message' do
VCR.use_cassette 'pushwoosh/push_notification' do
response = described_class.notify_all("Testing")
expect(response.status_code).to eq 200
end
end
end
context 'when message is empty' do
it 'raises a error if message is empty' do
VCR.use_cassette 'pushwoosh/empty_message_push' do
expect { described_class.notify_all("") }.to raise_error
end
end
end
end
end
|
Add PyCharm Community Edition 4.5.1 with bundled JDK 1.8 | cask :v1 => 'pycharm-ce-bundled-jdk' do
version '4.5.1'
sha256 '8929fa6e995a895244731a1ac2ab888593decb7d0592ba560280e845ee4ebe31'
url "https://download.jetbrains.com/python/pycharm-community-#{version}-jdk-bundled.dmg"
name 'PyCharm Community Edition'
homepage 'https://www.jetbrains.com/pycharm/'
license :apache
app 'PyCharm CE.app'
zap :delete => [
'~/Library/Preferences/com.jetbrains.pycharm.plist',
'~/Library/Preferences/PyCharm40',
'~/Library/Application Support/PyCharm40',
'~/Library/Caches/PyCharm40',
'~/Library/Logs/PyCharm40',
'/usr/local/bin/charm',
]
conflicts_with :cask => 'pycharm-ce'
end
| |
Add an homebrew external commad for auditing head-only formula | # This homebrew external command is used to override `brew audit`
# so that it will omit the HEAD only error.
#
# This file should be removed after neovim reaching stable release.
require "cmd/audit"
class FormulaAuditor
def audit_specs
end
end
Homebrew.audit
| |
Add a request spec for BalanceSheetController. | # -*- encoding : utf-8 -*-
require 'spec_helper'
describe BalanceSheetController do
fixtures :users, :accounts, :preferences
set_fixture_class :accounts => Account::Base
include_context "太郎 logged in"
before do
visit 'balance_sheet'
end
describe "メニュー「貸借対照表」のクリック" do
it "今月の貸借対照表が表示される" do
page.should have_content("#{Date.today.year}年#{Date.today.month}月末日の貸借対照表")
end
end
end | |
Make sure the job/queue metric is optional, for totals | module Resque
module Metrics
module Backends
class Statsd
attr_accessor :statsd, :stats_prefix
def initialize(stats, stats_prefix = 'resque')
@statsd = statsd
@stats_prefix = stats_prefix
end
def increment_metric(metric, by = 1)
if metric =~ /(.+)(?:_job)_(time|count)(?::(queue|job):(.*))$/
event = $1
event = 'complete' if event == 'job'
time_or_count = $2
queue_or_job = $3
queue_or_job_name = $4
key = if queue_or_job && queue_or_job_name
# ie resque.complete.queue.high.count, resque.failed.job.Index.timing
"#{stats_prefix}.#{event}.#{queue_or_job}.#{queue_or_job_name}.#{time_or_count}"
else
# ie resque.complete.time
"#{stats_prefix}.#{event}.#{time_or_count}"
end
case event
when 'time'
statsd.timing key, by
when 'count'
statsd.increment key, by
else
raise "Not sure how to handle #{$2} metric #{metric}"
end
else
raise "Not sure how to handle metric #{metric}"
end
end
# set_metric: we'll actually be dealing only in increments & timings for now
# set_avg: let statsd & graphite handle that
# get_metric: would have to talk to graphite. but man, complicated
end
end
end
end
| module Resque
module Metrics
module Backends
class Statsd
attr_accessor :statsd, :stats_prefix
def initialize(stats, stats_prefix = 'resque')
@statsd = statsd
@stats_prefix = stats_prefix
end
def increment_metric(metric, by = 1)
if metric =~ /(.+)(?:_job)_(time|count)(?::(queue|job):(.*))?$/
event = $1
event = 'complete' if event == 'job'
time_or_count = $2
queue_or_job = $3
queue_or_job_name = $4
key = if queue_or_job && queue_or_job_name
# ie resque.complete.queue.high.count, resque.failed.job.Index.timing
"#{stats_prefix}.#{event}.#{queue_or_job}.#{queue_or_job_name}.#{time_or_count}"
else
# ie resque.complete.time
"#{stats_prefix}.#{event}.#{time_or_count}"
end
case event
when 'time'
statsd.timing key, by
when 'count'
statsd.increment key, by
else
raise "Not sure how to handle #{$2} metric #{metric}"
end
else
raise "Not sure how to handle metric #{metric}"
end
end
# set_metric: we'll actually be dealing only in increments & timings for now
# set_avg: let statsd & graphite handle that
# get_metric: would have to talk to graphite. but man, complicated
end
end
end
end
|
Update OnyX to OS X Mavericks version | class Onyx < Cask
url 'http://joel.barriere.pagesperso-orange.fr/dl/108/OnyX.dmg'
homepage 'http://www.titanium.free.fr/downloadonyx.php'
version 'latest'
no_checksum
link 'OnyX.app'
end
| class Onyx < Cask
url 'http://joel.barriere.pagesperso-orange.fr/dl/109/OnyX.dmg'
homepage 'http://www.titanium.free.fr/downloadonyx.php'
version 'latest'
no_checksum
link 'OnyX.app'
def caveats; <<-EOS.undent
This version of OnyX is for OS X Mavericks only. If you are using other versions of OS X, please run 'brew tap caskroom/versions' and install onyx-mountainlion / onyx-lion / onyx-snowleopard
EOS
end
end
|
Add a blank line after a guard clause | class PipelineSerializer < BaseSerializer
InvalidResourceError = Class.new(StandardError)
entity PipelineEntity
def with_pagination(request, response)
tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end
def paginated?
@paginator.present?
end
def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation)
resource = resource.includes(project: :namespace)
end
if paginated?
super(@paginator.paginate(resource), opts)
else
super(resource, opts)
end
end
def represent_status(resource)
return {} unless resource.present?
data = represent(resource, { only: [{ details: [:status] }] })
data.dig(:details, :status) || {}
end
end
| class PipelineSerializer < BaseSerializer
InvalidResourceError = Class.new(StandardError)
entity PipelineEntity
def with_pagination(request, response)
tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end
def paginated?
@paginator.present?
end
def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation)
resource = resource.includes(project: :namespace)
end
if paginated?
super(@paginator.paginate(resource), opts)
else
super(resource, opts)
end
end
def represent_status(resource)
return {} unless resource.present?
data = represent(resource, { only: [{ details: [:status] }] })
data.dig(:details, :status) || {}
end
end
|
Build a universal binary on Leopard | require 'formula'
class Xdebug <Formula
url 'http://xdebug.org/files/xdebug-2.0.5.tgz'
homepage 'http://xdebug.org'
md5 '2d87dab7b6c499a80f0961af602d030c'
def install
Dir.chdir 'xdebug-2.0.5' do
system "phpize"
system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking",
"--enable-xdebug"
system "make"
prefix.install 'modules/xdebug.so'
end
end
def caveats
<<-END_CAVEATS
Add the following line to php.ini:
zend_extension="#{prefix}/xdebug.so"
Restart your webserver.
Write a PHP page that calls "phpinfo();" Load it in a browser and
look for the info on the xdebug module. If you see it, you have been
successful!
END_CAVEATS
end
end
| require 'formula'
class Xdebug <Formula
url 'http://xdebug.org/files/xdebug-2.0.5.tgz'
homepage 'http://xdebug.org'
md5 '2d87dab7b6c499a80f0961af602d030c'
def install
Dir.chdir 'xdebug-2.0.5' do
# See http://github.com/mxcl/homebrew/issues/#issue/69
ENV.universal_binary unless Hardware.is_64_bit?
system "phpize"
system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking",
"--enable-xdebug"
system "make"
prefix.install 'modules/xdebug.so'
end
end
def caveats
<<-END_CAVEATS
Add the following line to php.ini:
zend_extension="#{prefix}/xdebug.so"
Restart your webserver.
Write a PHP page that calls "phpinfo();" Load it in a browser and look for the
info on the xdebug module. If you see it, you have been successful!
END_CAVEATS
end
end
|
Add a new spec file for general library testing. | require 'spec_helper'
describe ApiVersions do
let(:testclass) { Class.new.extend ApiVersions }
it "should raise if no vendor string is provided" do
expect { testclass.api }.to raise_exception(RuntimeError, 'Please set a vendor_string for the api method')
end
end
| |
Use instance_exec in step definition too | require 'cucumber/core_ext/string'
module Cucumber
# A Step Definition holds a Regexp and a Proc, and is created
# by calling <tt>Given</tt>, <tt>When</tt> or <tt>Then</tt>
# in the <tt>step_definitions</tt> ruby files - for example:
#
# Given /I have (\d+) cucumbers in my belly/ do
# # some code here
# end
#
class StepDefinition
attr_reader :regexp
def initialize(regexp, &proc)
@regexp, @proc = regexp, proc
@proc.extend(CoreExt::CallIn)
end
#:stopdoc:
def match(step_name)
case step_name
when String then @regexp.match(step_name)
when Regexp then @regexp == step_name
end
end
def format_args(step_name, format)
step_name.gzub(@regexp, format)
end
def execute_by_name(world, step_name, *multiline_args)
args = step_name.match(@regexp).captures + multiline_args
execute(world, *args)
end
def execute(world, *args)
begin
@proc.call_in(world, *args)
rescue Exception => e
method_line = "#{__FILE__}:#{__LINE__ - 2}:in `execute'"
e.cucumber_strip_backtrace!(method_line, @regexp.to_s)
raise e
end
end
def file_colon_line
@proc.file_colon_line
end
end
end
| require 'cucumber/core_ext/string'
module Cucumber
# A Step Definition holds a Regexp and a Proc, and is created
# by calling <tt>Given</tt>, <tt>When</tt> or <tt>Then</tt>
# in the <tt>step_definitions</tt> ruby files - for example:
#
# Given /I have (\d+) cucumbers in my belly/ do
# # some code here
# end
#
class StepDefinition
attr_reader :regexp
def initialize(regexp, &proc)
@regexp, @proc = regexp, proc
@proc.extend(CoreExt::CallIn)
end
#:stopdoc:
def match(step_name)
case step_name
when String then @regexp.match(step_name)
when Regexp then @regexp == step_name
end
end
def format_args(step_name, format)
step_name.gzub(@regexp, format)
end
def execute_by_name(world, step_name, *multiline_args)
args = step_name.match(@regexp).captures + multiline_args
execute(world, *args)
end
def execute(world, *args)
begin
world.instance_exec(*args, &@proc)
rescue Exception => e
method_line = "#{__FILE__}:#{__LINE__ - 2}:in `execute'"
e.cucumber_strip_backtrace!(method_line, @regexp.to_s)
raise e
end
end
def file_colon_line
@proc.file_colon_line
end
end
end
|
Add an example node http server | # run with:
#
# bundle exec ./bin/opal ./doc/examples/node_http_server.rb
#
%x{
var http;
http = require('http');
}
module HTTP
class Server
%x{
var dom_class = http.Server;
#{self}['_proto'] = dom_class.prototype;
def = #{self}._proto;
dom_class.prototype._klass = #{self};
}
def self.__http__
Native(`http`)
end
alias_native :listen, :listen
def self.start options = {}, &block
host = options[:host] || '127.0.0.1'
port = options[:port] || 3000
server = __http__.createServer do |req, res|
req = Native(req)
res = Native(res)
status, headers, body = block.call(`req`)
res.writeHead(status, headers.to_n);
res.end(body.join(' '));
end
server.listen(port, host)
puts("Server running at http://#{host}:#{port}/");
server
end
end
end
util = Native(`require('util')`)
HTTP::Server.start port: 3000 do |env|
[200, {'Content-Type' => 'text/plain'}, ["Hello World!\n", util.inspect(env)]]
end
| |
Update HandbrakeCLI Nightly to v6985svn | cask :v1 => 'handbrakecli-nightly' do
version '6945svn'
sha256 '303289b4ed14f9053d1ccaf01bd440d33418a8303cdf9c69e0116d45cec5b9e3'
url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg"
homepage 'http://handbrake.fr'
license :gpl
binary 'HandBrakeCLI'
depends_on :macos => '>= :snow_leopard'
end
| cask :v1 => 'handbrakecli-nightly' do
version '6985svn'
sha256 'c2dd1a1c94dff36b74bbabea48d0361666208b94b305aa0e9b87aa182b6af989'
url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg"
homepage 'http://handbrake.fr'
license :gpl
binary 'HandBrakeCLI'
depends_on :macos => '>= :snow_leopard'
end
|
Add link to the now dead Camino browser | class Camino < Cask
url 'http://download.cdn.mozilla.net/pub/mozilla.org/camino/releases/en-US/Camino-2.1.2.dmg'
homepage 'http://caminobrowser.org/'
version '2.1.2'
sha1 '092dae4c85614cc1bbf76a3ce8335f1cc452d949'
end
| class Camino < Cask
url 'http://download.cdn.mozilla.net/pub/mozilla.org/camino/releases/en-US/Camino-2.1.2.dmg'
homepage 'http://caminobrowser.org/'
version '2.1.2'
sha1 '092dae4c85614cc1bbf76a3ce8335f1cc452d949'
link 'Camino.app'
end
|
Set default order to :random | require 'rails/all'
module RSpecRails
class Application < ::Rails::Application
end
end
require 'rspec/rails'
require 'ammeter/init'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
class RSpec::Core::ExampleGroup
def self.run_all(reporter=nil)
run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
end
end
RSpec.configure do |c|
c.before(:each) do
@real_world = RSpec.world
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
end
c.after(:each) do
RSpec.instance_variable_set(:@world, @real_world)
end
end | require 'rails/all'
module RSpecRails
class Application < ::Rails::Application
end
end
require 'rspec/rails'
require 'ammeter/init'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
class RSpec::Core::ExampleGroup
def self.run_all(reporter=nil)
run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
end
end
RSpec.configure do |config|
config.before(:each) do
@real_world = RSpec.world
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
end
config.after(:each) do
RSpec.instance_variable_set(:@world, @real_world)
end
config.order = :random
end
|
Update Charles.app to version 3.11b1 | cask :v1 => 'charles-beta' do
version '3.10b9'
sha256 '35955b18774e9b278d0db7c9cd996dee9beb3990c391ae1556f3ff5ad8aa8dbc'
url "http://www.charlesproxy.com/assets/release/#{version.gsub(/b\d$/, '')}/charles-proxy-#{version}-applejava.dmg"
homepage 'http://www.charlesproxy.com/download/beta/'
license :commercial
app 'Charles.app'
zap :delete => [
'~/Library/Application Support/Charles',
'~/Library/Preferences/com.xk72.charles.config',
]
end
| cask :v1 => 'charles-beta' do
version '3.11b1'
sha256 '05ebf3b95a84d16ca434d1d4611bff1373a9e90c76c8002d59607c1c78a04bed'
url "http://www.charlesproxy.com/assets/release/#{version.gsub(/b\d$/, '')}/charles-proxy-#{version}-applejava.dmg"
homepage 'http://www.charlesproxy.com/download/beta/'
license :commercial
app 'Charles.app'
zap :delete => [
'~/Library/Application Support/Charles',
'~/Library/Preferences/com.xk72.charles.config',
]
end
|
Fix IntellijIdea to use double quotes | class IntellijIdea < Cask
version '13.1.4'
sha256 'be5ca65ab5b169ac66f47f02f49d5d9359935c9f56140327a32f9da555d845bb'
url 'http://download-cf.jetbrains.com/idea/ideaIU-#{version}.dmg'
homepage 'https://www.jetbrains.com/idea/index.html'
link 'IntelliJ IDEA 13.app'
caveats do
<<-EOS.undent
#{@cask} may require Java 7 (an older version) available from the
caskroom-versions repo via
brew cask install caskroom/versions/java7
Alternatively, #{@cask} can be modified to use Java 8 as described in
https://github.com/caskroom/homebrew-cask/issues/4500#issuecomment-43955932
EOS
end
end
| class IntellijIdea < Cask
version '13.1.4'
sha256 'be5ca65ab5b169ac66f47f02f49d5d9359935c9f56140327a32f9da555d845bb'
url "http://download-cf.jetbrains.com/idea/ideaIU-#{version}.dmg"
homepage 'https://www.jetbrains.com/idea/index.html'
link 'IntelliJ IDEA 13.app'
caveats do
<<-EOS.undent
#{@cask} may require Java 7 (an older version) available from the
caskroom-versions repo via
brew cask install caskroom/versions/java7
Alternatively, #{@cask} can be modified to use Java 8 as described in
https://github.com/caskroom/homebrew-cask/issues/4500#issuecomment-43955932
EOS
end
end
|
Test to make sure exceptions are subclassable (map to native Error instances) | class ExceptionSubclassSpec < Exception
def nicer_message
message + ", but don't worry son - you'll learn"
end
end
describe "Exception subclasses" do
it "should correctly report the class" do
ExceptionSubclassSpec.new.class.should == ExceptionSubclassSpec
Exception.new.class.should == Exception
end
it "should copy the subclasses methods onto instances" do
msg = "it failed, but don't worry son - you'll learn"
ExceptionSubclassSpec.new("it failed").nicer_message.should == msg
end
end | |
Fix name/doc of regression spec GH-815 | describe 'GH-813', site: true, stdio: true do
before do
File.write('nanoc.yaml', "animal: \"donkey\"\n")
File.write('content/foo.md', '<%= @config.key?(:animal) %>')
File.write('Rules', <<EOS)
compile '/**/*' do
filter :erb
write item.identifier.without_ext + '.txt'
end
EOS
end
specify 'Nanoc generates diff for proper path' do
Nanoc::CLI.run(['compile'])
expect(File.read('output/foo.txt')).to eql('true')
end
end
| describe 'GH-815', site: true, stdio: true do
before do
File.write('nanoc.yaml', "animal: \"donkey\"\n")
File.write('content/foo.md', '<%= @config.key?(:animal) %>')
File.write('Rules', <<EOS)
compile '/**/*' do
filter :erb
write item.identifier.without_ext + '.txt'
end
EOS
end
it 'handles #key? properly' do
Nanoc::CLI.run(['compile'])
expect(File.read('output/foo.txt')).to eql('true')
end
end
|
Simplify implementation of build retry service | module Ci
class RetryBuildService < ::BaseService
def execute(build)
# return unless build.retryable?
self.retry(build).tap do |new_build|
MergeRequests::AddTodoWhenBuildFailsService
.new(build.project, current_user)
.close(new_build)
build.pipeline
.mark_as_processable_after_stage(build.stage_idx)
end
end
def retry(build)
self.reprocess(build).tap do |new_build|
new_build.enqueue!
end
end
def reprocess(build)
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
end
Ci::Build.create(
ref: build.ref,
tag: build.tag,
options: build.options,
commands: build.commands,
tag_list: build.tag_list,
project: build.project,
pipeline: build.pipeline,
name: build.name,
allow_failure: build.allow_failure,
stage: build.stage,
stage_idx: build.stage_idx,
trigger_request: build.trigger_request,
yaml_variables: build.yaml_variables,
when: build.when,
environment: build.environment,
user: current_user)
end
end
end
| module Ci
class RetryBuildService < ::BaseService
def execute(build)
reprocess(build).tap do |new_build|
new_build.enqueue!
MergeRequests::AddTodoWhenBuildFailsService
.new(build.project, current_user)
.close(new_build)
build.pipeline
.mark_as_processable_after_stage(build.stage_idx)
end
end
def reprocess(build)
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
end
Ci::Build.create(
ref: build.ref,
tag: build.tag,
options: build.options,
commands: build.commands,
tag_list: build.tag_list,
project: build.project,
pipeline: build.pipeline,
name: build.name,
allow_failure: build.allow_failure,
stage: build.stage,
stage_idx: build.stage_idx,
trigger_request: build.trigger_request,
yaml_variables: build.yaml_variables,
when: build.when,
environment: build.environment,
user: current_user)
end
end
end
|
Clean up one more mailer preview | # frozen_string_literal: true
class TicketNotificationMailerPreview < ActionMailer::Preview
def message_to_student
sender = User.new(username: 'admin',
real_name: 'Delano (Wiki Edu)',
permissions: User::Permissions::ADMIN)
recipient = User.new(username: 'flanagan.hyder')
TicketNotificationMailer.notify(
course:, message:, recipient:,
sender:, bcc_to_salesforce: false
)
end
def message_to_instructor
sender = User.new(username: 'flanagan.hyder')
recipient = User.new(username: 'admin',
real_name: 'Delano (Wiki Edu)',
permissions: User::Permissions::ADMIN)
TicketNotificationMailer.notify(
course:, message:, recipient:,
sender:, bcc_to_salesforce: false
)
end
def open_tickets_notification
owner = User.admin.first
tickets = TicketDispenser::Ticket.first(20)
TicketNotificationMailer.open_tickets_notify(
owner:,
tickets:
)
end
private
def course
Course.new(slug: 'course/title', title: 'My Course')
end
def message
content = %(
<p>Hi there,</p>
<p>Tabella et aspernatur verecundia comburo et averto addo abutor
caelestis sed adduco. Similique argentum deduco crustulum solium utrum
undique denique. Vesco surgo ex pauci aveho aperiam. Arx volutabrum
canonicus quo addo theatrum arcesso cognatus cohors. Tepidus auris qui
convoco ulterius bibo confugo.</p>
)
ticket = TicketDispenser::Ticket.first || TicketDispenser::Dispenser.call(
content:,
course:,
owner: recipient(:admin),
sender:
)
ticket.messages.last
end
end
| # frozen_string_literal: true
class TicketNotificationMailerPreview < ActionMailer::Preview
def message_to_student
sender = User.new(username: 'admin',
real_name: 'Delano (Wiki Edu)',
permissions: User::Permissions::ADMIN)
recipient = User.new(username: 'flanagan.hyder')
TicketNotificationMailer.notify(
course:, message:, recipient:,
sender:, bcc_to_salesforce: false
)
end
def message_to_instructor
sender = User.new(username: 'flanagan.hyder')
recipient = User.new(username: 'admin',
real_name: 'Delano (Wiki Edu)',
permissions: User::Permissions::ADMIN)
TicketNotificationMailer.notify(
course:, message:, recipient:,
sender:, bcc_to_salesforce: false
)
end
def open_tickets_notification
owner = User.admin.first
tickets = TicketDispenser::Ticket.first(20)
TicketNotificationMailer.open_tickets_notify(
owner:,
tickets:
)
end
private
def course
Course.new(slug: 'course/title', title: 'My Course')
end
def message
ticket = TicketDispenser::Ticket.first
ticket.messages.last
end
end
|
Make CodeError.code a reader again as the inheritance stuff is unneeded | # frozen_string_literal: true
module Discordrb
# Custom errors raised in various places
module Errors
# Raised when authentication data is invalid or incorrect.
class InvalidAuthenticationError < RuntimeError
# Default message for this exception
def message
'User login failed due to an invalid email or password!'
end
end
# Raised when a message is over the character limit
class MessageTooLong < RuntimeError; end
# Raised when the bot can't do something because its permissions on the server are insufficient
class NoPermission < RuntimeError; end
# Raised when the bot gets a HTTP 502 error, which is usually caused by Cloudflare.
class CloudflareError < RuntimeError; end
# Generic class for errors denoted by API error codes
class CodeError < RuntimeError
class << self
# @return [Integer] The error code represented by this error class.
def code
return @code if @code
# This class has no code, so search the superclasses
class_with_code = ancestors.find { |c| !c.code.nil? }
return class_with_code.code if class_with_code
# No superclass has a code for whatever reason
raise "Tried to get this error's code, but neither it nor any of its ancestors has one!"
end
end
# Create a new error with a particular message (the code should be defined by the class instance variable)
# @param message [String] the message to use
def initialize(message)
@message = message
end
end
# Create a new code error class
# rubocop:disable Style/MethodName
def self.Code(code)
classy = Class.new(CodeError)
classy.instance_variable_set('@code', code)
classy
end
end
end
| # frozen_string_literal: true
module Discordrb
# Custom errors raised in various places
module Errors
# Raised when authentication data is invalid or incorrect.
class InvalidAuthenticationError < RuntimeError
# Default message for this exception
def message
'User login failed due to an invalid email or password!'
end
end
# Raised when a message is over the character limit
class MessageTooLong < RuntimeError; end
# Raised when the bot can't do something because its permissions on the server are insufficient
class NoPermission < RuntimeError; end
# Raised when the bot gets a HTTP 502 error, which is usually caused by Cloudflare.
class CloudflareError < RuntimeError; end
# Generic class for errors denoted by API error codes
class CodeError < RuntimeError
class << self
# @return [Integer] The error code represented by this error class.
attr_reader :code
end
# Create a new error with a particular message (the code should be defined by the class instance variable)
# @param message [String] the message to use
def initialize(message)
@message = message
end
end
# Create a new code error class
# rubocop:disable Style/MethodName
def self.Code(code)
classy = Class.new(CodeError)
classy.instance_variable_set('@code', code)
classy
end
end
end
|
Add buffer api integration to post jobs on twitter automatically | class BufferApi
attr_accessor :client
def initialize
@client = Buffer::Client.new(AppSettings.buffer_access_token)
end
def post_new_job(job_id)
job = Job.find(job_id)
@client.create_update(
body: {
text:
"#{job.company_name.titleize} is looking to hire a '#{job.title}' in ##{job.location_name}. Check out the job details here https://#{AppSettings.application_host}/jobs/#{job.custom_identifier}.",
profile_ids: self.get_profile_id
}
)
end
def get_profile_id
@client.profiles.first._id
end
end
| |
Fix currently referenced invoice being included twice in suggestion list. | module InvoiceHelper
def invoice_states_as_collection
states = Invoice::STATES
states.inject({}) do |result, state|
result[t(state, :scope => 'invoice.state')] = state
result
end
end
def suggested_invoices_for_booking(booking)
invoices = Invoice.open_balance.where(:amount => booking.amount)
invoices << booking.reference if booking.reference
invoices.collect{|invoice| [invoice.to_s(:long), invoice.id]}
end
def invoice_label(invoice)
invoice_state_label(invoice.state)
end
def t_invoice_filter(state)
t(state, :scope => 'invoice.state')
end
def invoice_state_label(state, active = true)
type = case state.to_s
when 'canceled', 'reactivated'
nil
when 'paid'
'success'
when 'reminded', '2xreminded', '3xreminded', 'encashment'
'important'
when 'booked', 'written_off'
'info'
end
type = 'disabled' unless active
boot_label(t(state, :scope => 'invoice.state'), type)
end
end
| module InvoiceHelper
def invoice_states_as_collection
states = Invoice::STATES
states.inject({}) do |result, state|
result[t(state, :scope => 'invoice.state')] = state
result
end
end
def suggested_invoices_for_booking(booking)
invoices = Invoice.open_balance.where(:amount => booking.amount)
# Include currently referenced invoice
invoices << booking.reference if booking.reference
invoices = invoices.uniq
invoices.collect{|invoice| [invoice.to_s(:long), invoice.id]}
end
def invoice_label(invoice)
invoice_state_label(invoice.state)
end
def t_invoice_filter(state)
t(state, :scope => 'invoice.state')
end
def invoice_state_label(state, active = true)
type = case state.to_s
when 'canceled', 'reactivated'
nil
when 'paid'
'success'
when 'reminded', '2xreminded', '3xreminded', 'encashment'
'important'
when 'booked', 'written_off'
'info'
end
type = 'disabled' unless active
boot_label(t(state, :scope => 'invoice.state'), type)
end
end
|
Use bool instead of int for defaults write | class FLux < Cask
url 'https://justgetflux.com/mac/Flux.zip'
homepage 'http://justgetflux.com'
version 'latest'
no_checksum
link 'Flux.app'
after_install do
# Don't ask to move the app bundle to /Applications
system 'defaults write org.herf.Flux moveToApplicationsFolderAlertSuppress -int 1'
end
end
| class FLux < Cask
url 'https://justgetflux.com/mac/Flux.zip'
homepage 'http://justgetflux.com'
version 'latest'
no_checksum
link 'Flux.app'
after_install do
# Don't ask to move the app bundle to /Applications
system 'defaults write org.herf.Flux moveToApplicationsFolderAlertSuppress -bool true'
end
end
|
Use new class method to look for users via Slack UID | module Api
module V1
class InvitationsController < ApplicationController
skip_before_action :verify_authenticity_token
respond_to :json
# devise authentication required to access invitations
before_action :authenticate_user!, unless: :api_request
# POST /invitations
def create
@invitation = Invitation.new(invitation_params)
@invitation.medium = 'api'
@invitation.code_of_conduct = true
if user = User.where(uid: invitation_params[:slack_uid])
@invitation.user = user
end
if @invitation.save
render status: :created, json: { status: 201 }.to_json and return
else
render status: 422,
json: { message: @invitation.errors } and return
end
end
private
# Only allow a trusted parameter "white list" through.
def invitation_params
params.require(:invitation).permit(:slack_uid, :invitee_name,
:invitee_email, :invitee_title,
:invitee_company)
end
end
end
end
| module Api
module V1
class InvitationsController < ApplicationController
skip_before_action :verify_authenticity_token
respond_to :json
# devise authentication required to access invitations
before_action :authenticate_user!, unless: :api_request
# POST /invitations
def create
@invitation = Invitation.new(invitation_params)
@invitation.medium = 'api'
@invitation.code_of_conduct = true
if user = User.find_user_by_slack_uid(invitation_params[:slack_uid])
@invitation.user = user
end
if @invitation.save
render status: :created, json: { status: 201 }.to_json and return
else
render status: 422,
json: { message: @invitation.errors } and return
end
end
private
# Only allow a trusted parameter "white list" through.
def invitation_params
params.require(:invitation).permit(:slack_uid, :invitee_name,
:invitee_email, :invitee_title,
:invitee_company)
end
end
end
end
|
Set the default InvalidAuthenticationError message to the "User login failed" message | module Discordrb
# Custom errors raised in various places
module Errors
# Raised when authentication data is invalid or incorrect.
class InvalidAuthenticationError < RuntimeError; end
# Raised when a HTTP status code indicates a failure
class HTTPStatusError < RuntimeError
attr_reader :status
def initialize(status)
@status = status
end
end
# Raised when a message is over the character limit
class MessageTooLong < RuntimeError; end
# Raised when the bot can't do something because its permissions on the server are insufficient
class NoPermission < RuntimeError; end
# Raised when the bot gets a HTTP 502 error, which is usually caused by Cloudflare.
class CloudflareError < RuntimeError; end
end
end
| module Discordrb
# Custom errors raised in various places
module Errors
# Raised when authentication data is invalid or incorrect.
class InvalidAuthenticationError < RuntimeError
# Default message for this exception
def message
'User login failed due to an invalid email or password!'
end
end
# Raised when a HTTP status code indicates a failure
class HTTPStatusError < RuntimeError
attr_reader :status
def initialize(status)
@status = status
end
end
# Raised when a message is over the character limit
class MessageTooLong < RuntimeError; end
# Raised when the bot can't do something because its permissions on the server are insufficient
class NoPermission < RuntimeError; end
# Raised when the bot gets a HTTP 502 error, which is usually caused by Cloudflare.
class CloudflareError < RuntimeError; end
end
end
|
Fix array for multi repo | #
# Cookbook Name:: multi_repo
# Attribute:: default
#
# Copyright:: Copyright (c) 2012 Webtrends, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['multi_repo']['repo_path'] = "/srv/repo"
default['multi_repo']['repo_mount'] = "pdxstore10.netiq.dmz:/ifs/data/osdeploy/repo"
default['multi_repo']['sysadmin_email'] = ""
default['multi_repo']['chef_repo_path'] = ""
default['multi_repo']['repo_dropbox_path'] = "/root/repo_dropbox"
default['multi_repo']['extra_repo_subdirs'] = [ "tools" "product" "windows" "linux"] | #
# Cookbook Name:: multi_repo
# Attribute:: default
#
# Copyright:: Copyright (c) 2012 Webtrends, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['multi_repo']['repo_path'] = "/srv/repo"
default['multi_repo']['repo_mount'] = "pdxstore10.netiq.dmz:/ifs/data/osdeploy/repo"
default['multi_repo']['sysadmin_email'] = ""
default['multi_repo']['chef_repo_path'] = ""
default['multi_repo']['repo_dropbox_path'] = "/root/repo_dropbox"
default['multi_repo']['extra_repo_subdirs'] = [ "tools","product","windows","linux"] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.