Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix no method error in segment worker. | class AssignRecommendationsWorker
include Sidekiq::Worker
def perform(teacher_id)
teacher = User.find(teacher_id)
analytics = AssignRecommendationsAnalytics.new
analytics.track_activity_assignment(teacher)
end
end
| class AssignRecommendationsWorker
include Sidekiq::Worker
def perform(teacher_id)
teacher = User.find(teacher_id)
analytics = AssignRecommendationsAnalytics.new
analytics.track(teacher)
end
end
|
Add rake task to export the entire trade db in csv files and then zipped | require 'zip'
require 'fileutils'
namespace :export do
task :trade_db => :environment do
RECORDS_PER_FILE = 500000
ntuples = RECORDS_PER_FILE
offset = 0
i = 0
dir = 'tmp/trade_db_files/'
FileUtils.mkdir_p dir
begin
while(ntuples == RECORDS_PER_FILE) do
i = i + 1
query = Trade::ShipmentReportQueries.full_db_query(RECORDS_PER_FILE, offset)
results = ActiveRecord::Base.connection.execute query
ntuples = results.ntuples
columns = results.fields
columns.map do |column|
column.capitalize!
column.gsub! '_', ' '
end
values = results.values
Rails.logger.info("Query executed returning #{ntuples} records!")
filename = "trade_db_#{i}.csv"
Rails.logger.info("Processing batch number #{i} in #{filename}.")
File.open("#{dir}#{filename}", 'w') do |file|
file.write columns.join(',')
values.each do |record|
file.write "\n"
file.write record.join(',')
end
end
offset = offset + RECORDS_PER_FILE
end
Rails.logger.info("Trade database completely exported!")
zipfile = 'tmp/trade_db_files/trade_db.zip'
Zip::File.open(zipfile, Zip::File::CREATE) do |zipfile|
(1..i).each do |index|
filename = "trade_db_#{index}.csv"
zipfile.add(filename, dir + filename)
end
end
rescue => e
Rails.logger.info("Export aborted!")
Rails.logger.info("Caught exception #{e}")
Rails.logger.info(e.message)
end
end
end
| |
Add subject field to app delegate | class AppDelegate
attr_accessor :van_hoorden_sounds, :miller_and_heise_sounds, :window
def application(application, didFinishLaunchingWithOptions:launchOptions)
self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
start_experiment
end
def start_experiment
self.van_hoorden_sounds = NSFileManager.defaultManager.contentsOfDirectoryAtPath(NSBundle.mainBundle.resourcePath, error:nil).select {|file| file =~ /vn/}
self.van_hoorden_sounds.map! {|file| Tone.new(file)}
self.miller_and_heise_sounds = NSFileManager.defaultManager.contentsOfDirectoryAtPath(NSBundle.mainBundle.resourcePath, error:nil).select {|file| file =~ /mh/}
self.miller_and_heise_sounds.map! {|file| Tone.new(file)}
# NSLog "#{self.van_hoorden_sounds.size} #{self.miller_and_heise_sounds.size}"
self.window.rootViewController = TutorialController.new
self.window.makeKeyAndVisible
true
end
end
| class AppDelegate
attr_accessor :van_hoorden_sounds, :miller_and_heise_sounds, :window, :subject
def application(application, didFinishLaunchingWithOptions:launchOptions)
self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
start_experiment
end
def start_experiment
self.van_hoorden_sounds = NSFileManager.defaultManager.contentsOfDirectoryAtPath(NSBundle.mainBundle.resourcePath, error:nil).select {|file| file =~ /vn/}
self.van_hoorden_sounds.map! {|file| Tone.new(file)}
self.miller_and_heise_sounds = NSFileManager.defaultManager.contentsOfDirectoryAtPath(NSBundle.mainBundle.resourcePath, error:nil).select {|file| file =~ /mh/}
self.miller_and_heise_sounds.map! {|file| Tone.new(file)}
# NSLog "#{self.van_hoorden_sounds.size} #{self.miller_and_heise_sounds.size}"
self.window.rootViewController = TutorialController.new
self.window.makeKeyAndVisible
true
end
end
|
Add a specific message for changing a mapping type to unresolved | #encoding: utf-8
module VersionsHelper
def value_or_blank(value)
value.blank? ? '<blank>' : value
end
def friendly_changeset_title_for_type(value)
case value
when 'redirect'
'Switched mapping to a Redirect'
when 'archive'
'Switched mapping to an Archive'
else
'Switched mapping type'
end
end
def friendly_changeset_title(changeset)
if changeset['id']
'Mapping created'
elsif changeset['type']
friendly_changeset_title_for_type(changeset['type'][1])
elsif changeset.length == 1
first = changeset.first[0].titleize
first = 'Alternative Archive URL' if first == 'Archive URL'
"#{first} updated"
else
"Multiple properties updated"
end
end
def friendly_field_name(field)
case field
when 'archive_url'
'Alternative Archive URL'
else
field.titleize
end
end
def friendly_changeset_old_to_new(field, change)
old_value = value_or_blank(change[0])
new_value = value_or_blank(change[1])
if field == 'type'
old_value = change[0].titleize unless change[0].blank?
new_value = change[1].titleize unless change[1].blank?
end
"#{old_value} → #{new_value}"
end
end
| #encoding: utf-8
module VersionsHelper
def value_or_blank(value)
value.blank? ? '<blank>' : value
end
def friendly_changeset_title_for_type(value)
case value
when 'redirect'
'Switched mapping to a Redirect'
when 'archive'
'Switched mapping to an Archive'
when 'unresolved'
'Switched mapping to Unresolved'
else
'Switched mapping type'
end
end
def friendly_changeset_title(changeset)
if changeset['id']
'Mapping created'
elsif changeset['type']
friendly_changeset_title_for_type(changeset['type'][1])
elsif changeset.length == 1
first = changeset.first[0].titleize
first = 'Alternative Archive URL' if first == 'Archive URL'
"#{first} updated"
else
"Multiple properties updated"
end
end
def friendly_field_name(field)
case field
when 'archive_url'
'Alternative Archive URL'
else
field.titleize
end
end
def friendly_changeset_old_to_new(field, change)
old_value = value_or_blank(change[0])
new_value = value_or_blank(change[1])
if field == 'type'
old_value = change[0].titleize unless change[0].blank?
new_value = change[1].titleize unless change[1].blank?
end
"#{old_value} → #{new_value}"
end
end
|
Add restore production dump rake task | namespace :db do
dump_file = 'tmp/latest.dump'
def verify_exec(command)
system(command)
fail 'Command failed' unless $CHILD_STATUS.exitstatus.zero?
end
file dump_file do
verify_exec 'heroku pg:backups capture --app novel'
verify_exec "curl -o #{dump_file} `heroku pg:backups public-url -a novel`"
end
desc 'Download and restore prod db; requires heroku toolbelt and production db access'
task restore_production_dump: dump_file do
puts 'Restoring latest production data'
verify_exec "pg_restore --verbose --clean --no-acl --no-owner #{dump_file} | rails dbconsole"
puts 'Completed successfully!'
end
end
| |
Mark frame/in03 not pending (ordered) | # coding: utf-8
require_relative 'spec_helper'
describe JSON::LD do
describe "test suite" do
require_relative 'suite_helper'
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::FRAME_SUITE}frame-manifest.jsonld")
describe m.name do
m.entries.each do |t|
specify "#{t.property('@id')}: #{t.name} unordered#{' (negative test)' unless t.positiveTest?}" do
t.options[:ordered] = false
expect {t.run self}.not_to write.to(:error)
end
specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do
pending "Ordered version of in03" if %w(#tin03).include?(t.property('@id'))
t.options[:ordered] = true
expect {t.run self}.not_to write.to(:error)
end
end
end
end
end unless ENV['CI'] | # coding: utf-8
require_relative 'spec_helper'
describe JSON::LD do
describe "test suite" do
require_relative 'suite_helper'
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::FRAME_SUITE}frame-manifest.jsonld")
describe m.name do
m.entries.each do |t|
specify "#{t.property('@id')}: #{t.name} unordered#{' (negative test)' unless t.positiveTest?}" do
t.options[:ordered] = false
expect {t.run self}.not_to write.to(:error)
end
specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do
t.options[:ordered] = true
expect {t.run self}.not_to write.to(:error)
end
end
end
end
end unless ENV['CI'] |
Hide new action in admin for unapproved projects | require Rails.root.join('lib', 'rails_admin_approve_project.rb')
require Rails.root.join('lib', 'rails_admin_pin_news.rb')
RailsAdmin.config do |config|
### Popular gems integration
## == Devise ==
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
config.authorize_with do |controller|
redirect_to main_app.root_path unless current_user.admin?
end
## == Cancan ==
# config.authorize_with :cancan
## == PaperTrail ==
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app
approve_project do
only ['UnapprovedProject']
end
pin_news do
only ['News']
end
## With an audit adapter, you can add:
# history_index
# history_show
end
config.included_models = ["Project", "UnapprovedProject", "Contestant", "User", "Screenshot", "Edition", "News"]
end
| require Rails.root.join('lib', 'rails_admin_approve_project.rb')
require Rails.root.join('lib', 'rails_admin_pin_news.rb')
RailsAdmin.config do |config|
### Popular gems integration
## == Devise ==
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
config.authorize_with do |controller|
redirect_to main_app.root_path unless current_user.admin?
end
## == Cancan ==
# config.authorize_with :cancan
## == PaperTrail ==
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
config.actions do
dashboard # mandatory
index # mandatory
new do
except ['UnapprovedProject']
end
export
bulk_delete
show
edit
delete
show_in_app
approve_project do
only ['UnapprovedProject']
end
pin_news do
only ['News']
end
## With an audit adapter, you can add:
# history_index
# history_show
end
config.included_models = ["Project", "UnapprovedProject", "Contestant", "User", "Screenshot", "Edition", "News"]
end
|
Remove display name for now | module SparkpostRails
class DeliveryMethod
include HTTParty
base_uri "https://api.sparkpost.com/api/v1"
attr_accessor :settings, :response
def initialize(options = {})
@settings = options
end
def deliver!(mail)
data = {
:options => {
:open_tracking => SparkpostRails.configuration.track_opens,
:click_tracking => SparkpostRails.configuration.track_clicks
},
:campaign_id => "",
:recipients => [
{
:address => {
:name => mail.to_addrs.first.display_name,
:email => mail.to_addrs.first.address
}
}
],
:content => {
:from => {
:name => mail.from_addrs.first.display_name,
:email => mail.from_addrs.first.address
},
:subject => mail.subject,
:reply_to => mail.reply_to.first,
:text => mail.text_part,
:html => mail.html_part
}
}
headers = { "Authorization" => SparkpostRails.configuration.api_key }
post('/transmissions', { headers: headers, body: data })
@response = false
end
end
end
| module SparkpostRails
class DeliveryMethod
include HTTParty
base_uri "https://api.sparkpost.com/api/v1"
attr_accessor :settings, :response
def initialize(options = {})
@settings = options
end
def deliver!(mail)
data = {
:options => {
:open_tracking => SparkpostRails.configuration.track_opens,
:click_tracking => SparkpostRails.configuration.track_clicks
},
:campaign_id => "",
:recipients => [
{
:address => {
# :name => "",
:email => mail.to.first
}
}
],
:content => {
:from => {
# :name => "",
:email => mail.from.first
},
:subject => mail.subject,
:reply_to => mail.reply_to.first,
:text => mail.text_part,
:html => mail.html_part
}
}
headers = { "Authorization" => SparkpostRails.configuration.api_key }
post('/transmissions', { headers: headers, body: data })
@response = false
end
end
end
|
Make code and comments more readable | class SecretSanta
def self.create_list(names)
if names.length <= 2
"ERROR: List too short"
elsif names.length != names.uniq.length
"ERROR: Please enter unique names"
else
# shuffle names and create array (currently untested)
list = []
digraph_list = []
shuffled_names = names.dup.shuffle!
shuffled_names.each_with_index do |name, i|
list << "#{name} -> #{shuffled_names[i - 1]}"
end
# write the list to a dot file for graphviz
digraph_list = list.join("; ")
digraph = "digraph {#{digraph_list}}\n"
File.open('ss_list.dot', 'w') { |f| f.write("#{digraph}") }
# return the list
puts "-" * 40
puts "Secret Santa List:"
list
end
end
def self.solicit_input
puts "Enter each name in the Secret Santa pool, separated by a space:"
names = gets.downcase.chomp
create_list(names.split(" "))
end
end
| class SecretSanta
def self.create_list(names)
if names.length <= 2
"ERROR: List too short"
elsif names.length != names.uniq.length
"ERROR: Please enter unique names"
else
# shuffle names and build lists
list = []
digraph_list = []
names.shuffle!
names.each_with_index do |name, i|
list << "#{name} -> #{names[i - 1]}"
end
# write the list to a graphviz dot file
digraph_list = list.join("; ")
digraph = "digraph {#{digraph_list}}\n"
File.open('ss_list.dot', 'w') { |f| f.write("#{digraph}") }
# return the list
puts "-" * 40
puts "Secret Santa List:"
list
end
end
def self.solicit_input
puts "Enter each name in the Secret Santa pool, separated by a space:"
names = gets.downcase.chomp
create_list(names.split(" "))
end
end
|
Fix homepage to use SSL in doubleTwist Cask | cask :v1 => 'doubletwist' do
version '3.1.2'
sha256 '47975cc7517a6cf8c90362536a7feb53f0ff8af7d45866481d37cad2fcae4dac'
url "http://download.doubletwist.com/releases/mac/dT-#{version}-kronos-patch1-r11040/doubleTwist.dmg"
appcast 'http://download.doubletwist.com/mac/appcast.xml',
:sha256 => '63ad1487f6e129aa79b9724f9191a52aa1a31ec0c26de63a9d778c1dd709a815'
name 'doubleTwist'
homepage 'http://www.doubletwist.com/'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder
app 'doubleTwist.app'
zap :delete => [
'~/Library/Application Support/doubleTwist',
'~/Library/Preferences/com.doubleTwist.desktop.plist',
'~/Library/Caches/com.doubleTwist.desktop'
]
end
| cask :v1 => 'doubletwist' do
version '3.1.2'
sha256 '47975cc7517a6cf8c90362536a7feb53f0ff8af7d45866481d37cad2fcae4dac'
url "http://download.doubletwist.com/releases/mac/dT-#{version}-kronos-patch1-r11040/doubleTwist.dmg"
appcast 'http://download.doubletwist.com/mac/appcast.xml',
:sha256 => '63ad1487f6e129aa79b9724f9191a52aa1a31ec0c26de63a9d778c1dd709a815'
name 'doubleTwist'
homepage 'https://www.doubletwist.com/'
license :unknown # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder
app 'doubleTwist.app'
zap :delete => [
'~/Library/Application Support/doubleTwist',
'~/Library/Preferences/com.doubleTwist.desktop.plist',
'~/Library/Caches/com.doubleTwist.desktop'
]
end
|
Test for basic tag information | require File.join(File.dirname(__FILE__), 'helper')
class MP4FileTest < Test::Unit::TestCase
context "TagLib::MP4::File" do
setup do
@file = TagLib::MP4::File.new("test/data/mp4.m4a")
end
should "have a tag" do
tag = @file.tag
assert_not_nil tag
assert_equal TagLib::Tag, tag.class
end
teardown do
@file.close
@file = nil
end
end
end
| require File.join(File.dirname(__FILE__), 'helper')
class MP4FileTest < Test::Unit::TestCase
context "TagLib::MP4::File" do
setup do
@file = TagLib::MP4::File.new("test/data/mp4.m4a")
@tag = @file.tag
end
should "contain basic tag information" do
assert_equal "Title", @tag.title
assert_equal "Artist", @tag.artist
assert_equal "Album", @tag.album
assert_equal "Comment", @tag.comment
assert_equal "Pop", @tag.genre
assert_equal 2011, @tag.year
assert_equal 7, @tag.track
assert_equal false, @tag.empty?
end
teardown do
@file.close
@file = nil
end
end
end
|
Add helper for soft hyphenation | module ApplicationHelper
include GravatarHelper
def shorter_url(url, length)
s = url.gsub(%r(http[s]?://(www\.)?), '')
truncate(s, :length => length)
end
def kronos_to_s(kronos_hash)
return '?' if kronos_hash.blank?
k = Kronos.from_hash(kronos_hash)
k.valid? ? k.to_s : '?'
end
def kronos_range_to_s(k1, k2)
s1, s2 = kronos_to_s(k1), kronos_to_s(k2)
(s1 == '?' || s2 == '?') ? '?' : "#{s1} to #{s2}"
end
def try_link_to(text, url)
if text.present? && url.present?
link_to(text, url)
elsif text.present?
text
elsif url.present?
link_to('link', url)
else
'?'
end
end
def url_only(url, length)
url.present? ? link_to(shorter_url(url, length), url) : '?'
end
def tab(css_class, text, path)
classes = [css_class]
classes << 'active' if current_page?(path)
content_tag(:li, :class => classes.join(' ')) do
link_to(text, path)
end
end
end
| module ApplicationHelper
include GravatarHelper
# 'shy;' is the HTML entity for a soft hyphen
def hypenate(string)
string.gsub('-', '­').html_safe
end
def shorter_url(url, length)
s = url.gsub(%r(http[s]?://(www\.)?), '')
truncate(s, :length => length)
end
def kronos_to_s(kronos_hash)
return '?' if kronos_hash.blank?
k = Kronos.from_hash(kronos_hash)
k.valid? ? k.to_s : '?'
end
def kronos_range_to_s(k1, k2)
s1, s2 = kronos_to_s(k1), kronos_to_s(k2)
(s1 == '?' || s2 == '?') ? '?' : "#{s1} to #{s2}"
end
def try_link_to(text, url)
if text.present? && url.present?
link_to(text, url)
elsif text.present?
text
elsif url.present?
link_to('link', url)
else
'?'
end
end
def url_only(url, length)
url.present? ? link_to(shorter_url(url, length), url) : '?'
end
def tab(css_class, text, path)
classes = [css_class]
classes << 'active' if current_page?(path)
content_tag(:li, :class => classes.join(' ')) do
link_to(text, path)
end
end
end
|
Enable cc.rb semi-hack for all projects | #!/usr/bin/env ruby
# Yes, this could be more abstracted, etc. Choosing explicitness for now.
# svn co and rake co need to be in same exec, or cruise just ends build after svn returns
#
# Intentionally doing svn co and rake cruise in separate processes to ensure that all of the
# local overrides are loaded by Rake.
project_name = ARGV.first
case project_name
when "racing_on_rails"
exec("rake cruise")
when "aba"
exec("svn co svn+ssh://cruise@butlerpress.com/var/repos/aba/trunk local && rake cruise")
when "atra"
exec('svn propset "svn:externals" "local svn+ssh://butlerpress.com/var/repos/atra/trunk" . && rake cruise')
when "obra"
exec("svn co svn+ssh://cruise@butlerpress.com/var/repos/obra/trunk local && rake cruise")
when "wsba"
exec("svn co svn+ssh://cruise@butlerpress.com/var/repos/wsba/trunk local && rake cruise")
else
raise "Don't know how to build project named: '#{project_name}'"
end
| #!/usr/bin/env ruby
# The svn:externals is a bit of a hack, but seems like the easiest solution to pulling in different projects
#
# Intentionally doing svn co and rake cruise in separate processes to ensure that all of the
# local overrides are loaded by Rake.
project_name = ARGV.first
case project_name
when "racing_on_rails"
exec("rake cruise")
when "aba", "atra", "obra", "wsba"
exec(%Q{svn propset "svn:externals" "local svn+ssh://butlerpress.com/var/repos/#{project}/trunk" . && rake cruise})
else
raise "Don't know how to build project named: '#{project_name}'"
end
|
Put longer cache time on operator pages. | class OperatorsController < ApplicationController
def show
@operator = Operator.find(params[:id])
@routes = Route.find(:all, :conditions => ["id in (SELECT route_id
FROM route_operators
WHERE operator_id = #{@operator.id})"],
:include => :slug,
:order => 'cached_description asc')
@stations = StopArea.find(:all, :conditions => ["id in (SELECT stop_area_id
FROM stop_area_operators
WHERE operator_id = #{@operator.id})"],
:include => :slug,
:order => 'name asc')
@route_count = Operator.connection.select_value("SELECT count(DISTINCT routes.id) AS count_routes_id
FROM routes
INNER JOIN route_operators
ON routes.id = route_operators.route_id
WHERE (route_operators.operator_id = #{@operator.id})").to_i
@station_count = Operator.connection.select_value("SELECT count(DISTINCT stop_areas.id)
AS count_stop_areas_id
FROM stop_areas
INNER JOIN stop_area_operators
ON stop_areas.id = stop_area_operators.stop_area_id
WHERE (stop_area_operators.operator_id = #{@operator.id})").to_i
end
end | class OperatorsController < ApplicationController
skip_before_filter :make_cachable
before_filter :long_cache
def show
@operator = Operator.find(params[:id])
@routes = Route.find(:all, :conditions => ["id in (SELECT route_id
FROM route_operators
WHERE operator_id = #{@operator.id})"],
:include => :slug,
:order => 'cached_description asc')
@stations = StopArea.find(:all, :conditions => ["id in (SELECT stop_area_id
FROM stop_area_operators
WHERE operator_id = #{@operator.id})"],
:include => :slug,
:order => 'name asc')
@route_count = Operator.connection.select_value("SELECT count(DISTINCT routes.id) AS count_routes_id
FROM routes
INNER JOIN route_operators
ON routes.id = route_operators.route_id
WHERE (route_operators.operator_id = #{@operator.id})").to_i
@station_count = Operator.connection.select_value("SELECT count(DISTINCT stop_areas.id)
AS count_stop_areas_id
FROM stop_areas
INNER JOIN stop_area_operators
ON stop_areas.id = stop_area_operators.stop_area_id
WHERE (stop_area_operators.operator_id = #{@operator.id})").to_i
end
end |
Exclude :live specs by default | require 'rubygems'
require 'bundler/setup'
require 'awesome_print'
require 'webmock/rspec'
require 'vcr'
require 'docker'
require 'helpers'
VCR.configure do |config|
config.cassette_library_dir = 'spec/cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
# :none replays all requests
# :once record if no casette available, otherwise replay or error
# :all re-record all request
# config.default_cassette_options = {:record => :all}
end
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
config.include Helpers
end
| require 'rubygems'
require 'bundler/setup'
require 'awesome_print'
require 'webmock/rspec'
require 'vcr'
require 'docker'
require 'helpers'
VCR.configure do |config|
config.cassette_library_dir = 'spec/cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
# :none replays all requests
# :once record if no casette available, otherwise replay or error
# :all re-record all request
# config.default_cassette_options = {:record => :all}
end
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.filter_run_excluding :live
config.order = 'random'
config.include Helpers
end
|
Fix rake version incompatibility by pinning to rake 10.5 on ruby < 1.9.3 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "readingtime/version"
Gem::Specification.new do |s|
s.name = "readingtime"
s.version = Readingtime::VERSION
s.authors = ["Gareth Rees"]
s.email = ["gareth@garethrees.co.uk"]
s.homepage = "http://github.com/garethrees/readingtime"
s.summary = %q{Estimates reading time}
s.description = %q{Estimates reading time of a Ruby String object}
s.rubyforge_project = "readingtime"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_development_dependency 'rake'
s.add_development_dependency "rspec", "~>2.6"
end
| # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "readingtime/version"
Gem::Specification.new do |s|
s.name = "readingtime"
s.version = Readingtime::VERSION
s.authors = ["Gareth Rees"]
s.email = ["gareth@garethrees.co.uk"]
s.homepage = "http://github.com/garethrees/readingtime"
s.summary = %q{Estimates reading time}
s.description = %q{Estimates reading time of a Ruby String object}
s.rubyforge_project = "readingtime"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_development_dependency 'rake', '~> 10.5.0' if RUBY_VERSION < '1.9.3' # see: https://github.com/travis-ci/travis.rb/issues/380
s.add_development_dependency 'rake' unless RUBY_VERSION < '1.9.3'
s.add_development_dependency "rspec", "~>2.6"
end
|
Raise error if duplicate controls block given. | #
# Author:: Tyler Ball (<tball@getchef.com>)
# Copyright:: Copyright (c) 2014 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# 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.
#
class Chef
module DSL
module Audit
# Can encompass tests in a `control` block or `describe` block
# Adds the controls group and block (containing controls to execute) to the runner's list of pending examples
def controls(*args, &block)
raise ::Chef::Exceptions::NoAuditsProvided unless block
name = args[0]
raise AuditNameMissing if name.nil? || name.empty?
run_context.controls[name] = { :args => args, :block => block }
end
end
end
end
| #
# Author:: Tyler Ball (<tball@getchef.com>)
# Copyright:: Copyright (c) 2014 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# 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.
#
require 'chef/exceptions'
class Chef
module DSL
module Audit
# Can encompass tests in a `control` block or `describe` block
# Adds the controls group and block (containing controls to execute) to the runner's list of pending examples
def controls(*args, &block)
raise Chef::Exceptions::NoAuditsProvided unless block
name = args[0]
if name.nil? || name.empty?
raise Chef::Exceptions::AuditNameMissing
elsif run_context.controls.has_key?(name)
raise Chef::Exceptions::AuditControlGroupDuplicate.new(name)
end
run_context.controls[name] = { :args => args, :block => block }
end
end
end
end
|
Add semantic versioning for rake dev dependency | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'building_blocks/version'
Gem::Specification.new do |spec|
spec.name = 'building_blocks'
spec.version = BuildingBlocks::VERSION
spec.authors = ['Danny Guinther']
spec.email = ['dannyguinther@gmail.com']
spec.summary = %q{Block-based Object Builders}
spec.description = %q{Simple DSL for defining block-based Object builders}
spec.homepage = 'https://github.com/interval-braining/building_blocks'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0")
spec.test_files = spec.files.grep(%r{^test/})
spec.require_paths = ['lib']
spec.add_development_dependency 'bundler', '~> 1.5'
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 'building_blocks/version'
Gem::Specification.new do |spec|
spec.name = 'building_blocks'
spec.version = BuildingBlocks::VERSION
spec.authors = ['Danny Guinther']
spec.email = ['dannyguinther@gmail.com']
spec.summary = %q{Block-based Object Builders}
spec.description = %q{Simple DSL for defining block-based Object builders}
spec.homepage = 'https://github.com/interval-braining/building_blocks'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0")
spec.test_files = spec.files.grep(%r{^test/})
spec.require_paths = ['lib']
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'rake', '~> 0'
end
|
Update to rspec's expect syntax | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
Dir.glob('locales/*.yml').each do |locale_file|
describe "a kaminari-i18n #{locale_file} locale file" do
it_behaves_like 'a valid locale file', locale_file
it { locale_file.should be_a_subset_of 'locales/en.yml' }
end
end
| require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
Dir.glob('locales/*.yml').each do |locale_file|
describe locale_file do
it_behaves_like 'a valid locale file', locale_file
it { is_expected.to be_a_subset_of 'locales/en.yml' }
end
end
|
Add plugin type metadata and bump version to 0.0.2. | Gem::Specification.new do |spec|
spec.name = "lita-google"
spec.version = "0.0.1"
spec.authors = ["Jimmy Cuadra"]
spec.email = ["jimmy@jimmycuadra.com"]
spec.description = %q{A Lita handler for returning Google search results.}
spec.summary = %q{A Lita handler for returning Google search results.}
spec.homepage = "https://github.com/jimmycuadra/lita-google"
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_runtime_dependency "lita", "~> 2.6"
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", ">= 2.14"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "coveralls"
end
| Gem::Specification.new do |spec|
spec.name = "lita-google"
spec.version = "0.0.2"
spec.authors = ["Jimmy Cuadra"]
spec.email = ["jimmy@jimmycuadra.com"]
spec.description = %q{A Lita handler for returning Google search results.}
spec.summary = %q{A Lita handler for returning Google search results.}
spec.homepage = "https://github.com/jimmycuadra/lita-google"
spec.license = "MIT"
spec.metadata = { "lita_plugin_type" => "handler" }
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_runtime_dependency "lita", "~> 2.6"
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", ">= 2.14"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "coveralls"
end
|
Add test helper method for using paper_trail | ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'webmock/test_unit'
require 'fixtures/factories'
require 'fixtures/mock_book_metadata_lookup'
require 'mocha/setup'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
WebMock.disable_net_connect!
include Warden::Test::Helpers
class ActiveSupport::TestCase
def setup
DatabaseCleaner.start
Book.metadata_lookup = MockBookMetadataLookup.new # stub the metadata lookup class in tests
end
def teardown
DatabaseCleaner.clean
end
def login_as_stub_user
@user = FactoryGirl.create(:user, :name => 'Ian Fleming')
request.env['warden'] = stub(:authenticate! => true, :authenticated? => true, :user => @user)
end
end
| ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'webmock/test_unit'
require 'fixtures/factories'
require 'fixtures/mock_book_metadata_lookup'
require 'mocha/setup'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
WebMock.disable_net_connect!
include Warden::Test::Helpers
class ActiveSupport::TestCase
def setup
DatabaseCleaner.start
Book.metadata_lookup = MockBookMetadataLookup.new # stub the metadata lookup class in tests
end
def teardown
DatabaseCleaner.clean
end
def login_as_stub_user
@user = FactoryGirl.create(:user, :name => 'Ian Fleming')
request.env['warden'] = stub(:authenticate! => true, :authenticated? => true, :user => @user)
end
# https://github.com/airblade/paper_trail#globally
def with_versioning
was_enabled = PaperTrail.enabled?
PaperTrail.enabled = true
begin
yield
ensure
PaperTrail.enabled = was_enabled
end
end
end
|
Load Turn in test helper | require 'simplecov'
SimpleCov.start
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'factory_girl'
require 'shoulda/context'
require 'shoulda/matchers'
class ActiveSupport::TestCase
include FactoryGirl::Syntax::Methods
include Shoulda::Matchers::ActiveRecord
extend Shoulda::Matchers::ActiveRecord
include Shoulda::Matchers::ActiveModel
extend Shoulda::Matchers::ActiveModel
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
| require 'simplecov'
SimpleCov.start
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'turn/autorun'
require 'factory_girl'
require 'shoulda/context'
require 'shoulda/matchers'
class ActiveSupport::TestCase
include FactoryGirl::Syntax::Methods
include Shoulda::Matchers::ActiveRecord
extend Shoulda::Matchers::ActiveRecord
include Shoulda::Matchers::ActiveModel
extend Shoulda::Matchers::ActiveModel
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
|
Add pry-nav as dev dependency | Gem::Specification.new do |s|
s.name = 'i18n-hygiene'
s.version = '0.1.0'
s.license = 'MIT'
s.summary = "Helps maintain translations."
s.description = "Provides rake tasks to help maintain translations."
s.authors = [ "Nick Browne"," Keith Pitty" ]
s.email = "dev@theconversation.edu.au"
s.files = `git ls-files -- lib/*`.split("\n")
s.homepage = 'https://github.com/conversation/i18n-hygiene'
s.add_dependency 'i18n', ['~> 0.6', '>= 0.6.9']
s.add_dependency 'parallel', '~> 1.3'
s.add_dependency 'rake', '~> 11.0.0'
s.add_development_dependency 'rspec', '~> 3.0'
end
| Gem::Specification.new do |s|
s.name = 'i18n-hygiene'
s.version = '0.1.0'
s.license = 'MIT'
s.summary = "Helps maintain translations."
s.description = "Provides rake tasks to help maintain translations."
s.authors = [ "Nick Browne"," Keith Pitty" ]
s.email = "dev@theconversation.edu.au"
s.files = `git ls-files -- lib/*`.split("\n")
s.homepage = 'https://github.com/conversation/i18n-hygiene'
s.add_dependency 'i18n', ['~> 0.6', '>= 0.6.9']
s.add_dependency 'parallel', '~> 1.3'
s.add_dependency 'rake', '~> 11.0.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'pry-nav'
end
|
Clarify comment regarding RSpec 2 and 3. | module Warp
class Matcher
# Composable matchers are new in RSpec 3.
# Define basic helpers in their absence.
if defined?(RSpec::Matchers::Composable)
include RSpec::Matchers::Composable
else
def description_of(object)
object.inspect
end
def values_match?(expected, actual)
expected === actual || actual == expected
end
end
# RSpec 2
if RSpec::Version::STRING[0] == "2"
def failure_message_for_should
failure_message
end
def failure_message_for_should_not
failure_message_when_negated
end
end
end
end | module Warp
class Matcher
# Composable matchers are new in RSpec 3.
# Define basic helpers in their absence.
if defined?(RSpec::Matchers::Composable)
include RSpec::Matchers::Composable
else
def description_of(object)
object.inspect
end
def values_match?(expected, actual)
expected === actual || actual == expected
end
end
# RSpec 2 and 3 have different methods
# that they call on matcher to get the
# failure messages.
if RSpec::Version::STRING[0] == "2"
def failure_message_for_should
failure_message
end
def failure_message_for_should_not
failure_message_when_negated
end
end
end
end |
Allow values like `--123` for slug | require 'simple_slug/version'
require 'active_support/core_ext'
require 'simple_slug/model_addition'
require 'simple_slug/railtie' if Object.const_defined?(:Rails)
module SimpleSlug
autoload :HistorySlug, 'simple_slug/history_slug'
mattr_accessor :excludes
@@excludes = %w(new edit show index session login logout sign_in sign_out users admin stylesheets assets javascripts images)
mattr_accessor :slug_regexp
@@slug_regexp = /\A\w+[\w\d\-_]*\z/
mattr_accessor :slug_column
@@slug_column = 'slug'
mattr_accessor :max_length
@@max_length = 240
mattr_accessor :callback_type
@@callback_type = :before_validation
mattr_accessor :add_validation
@@add_validation = true
STARTS_WITH_NUMBER_REGEXP =/\A\d+/
CYRILLIC_LOCALES = [:uk, :ru, :be].freeze
def self.setup
yield self
end
def self.normalize_cyrillic(base)
base.tr('АаВЕеіКкМНОоРрСсТуХх', 'AaBEeiKkMHOoPpCcTyXx')
end
end
| require 'simple_slug/version'
require 'active_support/core_ext'
require 'simple_slug/model_addition'
require 'simple_slug/railtie' if Object.const_defined?(:Rails)
module SimpleSlug
autoload :HistorySlug, 'simple_slug/history_slug'
mattr_accessor :excludes
@@excludes = %w(new edit show index session login logout sign_in sign_out users admin stylesheets assets javascripts images)
mattr_accessor :slug_regexp
@@slug_regexp = /\A(?:\w+[\w\d\-_]*|--\d+)\z/
mattr_accessor :slug_column
@@slug_column = 'slug'
mattr_accessor :max_length
@@max_length = 240
mattr_accessor :callback_type
@@callback_type = :before_validation
mattr_accessor :add_validation
@@add_validation = true
STARTS_WITH_NUMBER_REGEXP =/\A\d+/
CYRILLIC_LOCALES = [:uk, :ru, :be].freeze
def self.setup
yield self
end
def self.normalize_cyrillic(base)
base.tr('АаВЕеіКкМНОоРрСсТуХх', 'AaBEeiKkMHOoPpCcTyXx')
end
end
|
Add some description to gemspec | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'nyaplot/version'
Gem::Specification.new do |spec|
spec.name = "nyaplot"
spec.version = Nyaplot::VERSION
spec.authors = ["domitry"]
spec.email = ["domitry@gmail.com"]
spec.summary = %q{the Ruby front-end library of Ecoli.js}
spec.description = %q{the Ruby front-end library of Ecoli.js}
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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.5"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "pry"
end
| # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'nyaplot/version'
Gem::Specification.new do |spec|
spec.name = "nyaplot"
spec.version = Nyaplot::VERSION
spec.authors = ["Naoki Nishida"]
spec.email = ["domitry@gmail.com"]
spec.summary = %q{interactive plots generator for Ruby users}
spec.description = %q{To get information about Nyaplot, visit the website or mailing-list of SciRuby, or ask me on GitHub.}
spec.homepage = "https://www.github.com/domitry/nyaplot"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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.5"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "pry"
end
|
Remove plugin reload on development | require 'noosfero/plugin'
require 'noosfero/plugin/hot_spot'
require 'noosfero/plugin/manager'
require 'noosfero/plugin/active_record'
require 'noosfero/plugin/mailer_base'
require 'noosfero/plugin/settings'
require 'noosfero/plugin/spammable'
Noosfero::Plugin.init_system if $NOOSFERO_LOAD_PLUGINS
if Rails.env == 'development' && $NOOSFERO_LOAD_PLUGINS
ActionController::Base.send(:prepend_before_filter) do |controller|
Noosfero::Plugin.init_system
end
end
| require 'noosfero/plugin'
require 'noosfero/plugin/hot_spot'
require 'noosfero/plugin/manager'
require 'noosfero/plugin/active_record'
require 'noosfero/plugin/mailer_base'
require 'noosfero/plugin/settings'
require 'noosfero/plugin/spammable'
Noosfero::Plugin.init_system if $NOOSFERO_LOAD_PLUGINS
|
Use namespace ROMSpec in specs | # encoding: utf-8
# this is needed for guard to work, not sure why :(
require "bundler"
Bundler.setup
if RUBY_ENGINE == "rbx"
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
end
require 'rom'
begin
require 'byebug'
rescue LoadError
end
root = Pathname(__FILE__).dirname
Dir[root.join('support/*.rb').to_s].each { |f| require f }
Dir[root.join('shared/*.rb').to_s].each { |f| require f }
RSpec.configure do |config|
config.before do
@constants = Object.constants
end
config.after do
added_constants = Object.constants - @constants - [:ThreadSafe]
added_constants.each { |name| Object.send(:remove_const, name) }
end
end
| # encoding: utf-8
# this is needed for guard to work, not sure why :(
require "bundler"
Bundler.setup
if RUBY_ENGINE == "rbx"
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
end
require 'rom'
begin
require 'byebug'
rescue LoadError
end
root = Pathname(__FILE__).dirname
Dir[root.join('support/*.rb').to_s].each { |f| require f }
Dir[root.join('shared/*.rb').to_s].each { |f| require f }
# Namespace holding all objects created during specs
module ROMSpec
end
RSpec.configure do |config|
config.after do
added_constants = ROMSpec.constants
added_constants.each { |name| ROMSpec.send(:remove_const, name) }
end
end
|
Add spec helper that loads Watir | $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../commonwatir/lib")
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../watir/lib")
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../firewatir/lib")
require "watir"
case ENV['watir_browser']
when /firefox/
Browser = FireWatir::Firefox
else
Browser = Watir::IE
WatirSpec.persistent_browser = true
end
include Watir::Exception
| |
Add keys and start up tentacles. | # encoding: utf-8
#
# Cookbook Name:: octohost
# Recipe:: rackspace
#
# Copyright (C) 2014, Darron Froese <darron@froese.org>
#
# 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.
#
bash 'Update PRIVATE_IP for rackspace.' do
user 'root'
cwd '/tmp'
code <<-EOH
sed -i '6s/.*/PRIVATE_IP=\$(ifconfig eth1 \| grep \"inet addr\" \| cut --delimiter=\":\" -f 2 \| cut --delimiter=\" \" -f 1)/' /etc/default/octohost
EOH
end
| # encoding: utf-8
#
# Cookbook Name:: octohost
# Recipe:: rackspace
#
# Copyright (C) 2014, Darron Froese <darron@froese.org>
#
# 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.
#
bash 'Update PRIVATE_IP for rackspace.' do
user 'root'
cwd '/tmp'
code <<-EOH
sed -i '6s/.*/PRIVATE_IP=\$(ifconfig eth1 \| grep \"inet addr\" \| cut --delimiter=\":\" -f 2 \| cut --delimiter=\" \" -f 1)/' /etc/default/octohost
EOH
end
execute 'install keys to push to git user' do # ~FC041
command "curl -L #{node['git']['keys']} >> /home/git/.ssh/authorized_keys"
end
bash 'start tentacles' do
user 'root'
cwd '/tmp'
code <<-EOH
octo tentacles start
EOH
end
|
Add order option to the relation. | require 'active_force/query'
module ActiveForce
module Association
module ClassMethods
def has_many relation_name, options = {}
model = options[:model] || relation_model(relation_name)
association_name = options[:table] || model.table_name || "#{ model }__c"
foreing_key = options[:foreing_key] || default_foreing_key(model, self.name) || table_name
define_method "#{ relation_name }_query" do
query = ActiveForce::Query.new(association_name)
query.fields model.fields
query.where(options[:where]) if options[:where]
query.where("#{ foreing_key } = '#{ id }'")
query
end
end
def relation_model sym
sym.to_s.singularize.camelcase.constantize
end
def default_foreing_key relation_model, model
relation_model.mappings["#{model.downcase}_id".to_sym]
end
end
end
end | require 'active_force/query'
module ActiveForce
module Association
module ClassMethods
def has_many relation_name, options = {}
model = options[:model] || relation_model(relation_name)
association_name = options[:table] || model.table_name || "#{ model }__c"
foreing_key = options[:foreing_key] || default_foreing_key(model, self.name) || table_name
define_method "#{ relation_name }_query" do
query = ActiveForce::Query.new(association_name)
query.fields model.fields
query.where(options[:where]) if options[:where]
query.order(options[:order]) if options[:order]
query.where("#{ foreing_key } = '#{ id }'")
query
end
end
def relation_model sym
sym.to_s.singularize.camelcase.constantize
end
def default_foreing_key relation_model, model
relation_model.mappings["#{model.downcase}_id".to_sym]
end
end
end
end |
Add test 'APPBOY_TEST_SEGMENT' default value | require 'pry'
require 'dotenv'
require 'bundler/setup'
Bundler.setup
Dotenv.load
require 'appboy'
require 'support/vcr'
require 'support/factory_girl'
require 'support/integrations'
RSpec.configure do |config|
def test_time
Time.parse('2016-12-15 00:00:00 -0500').utc
end
def appboy_group_id
::ENV.fetch('APPBOY_GROUP_ID', 'fake-group-id')
end
def appboy_test_segment
::ENV.fetch('APPBOY_TEST_SEGMENT')
end
end
| require 'pry'
require 'dotenv'
require 'bundler/setup'
Bundler.setup
Dotenv.load
require 'appboy'
require 'support/vcr'
require 'support/factory_girl'
require 'support/integrations'
RSpec.configure do |config|
def test_time
Time.parse('2016-12-15 00:00:00 -0500').utc
end
def appboy_group_id
::ENV.fetch('APPBOY_GROUP_ID', 'fake-group-id')
end
def appboy_test_segment
::ENV.fetch('APPBOY_TEST_SEGMENT', 'fake-test-segment')
end
end
|
Update podspec with new project name | #
# Be sure to run `pod lib lint TestLib.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'HSContainerController'
s.version = File.read('VERSION')
s.summary = 'Lightweight Swift Framework for iOS which let you replace UIViewController in UIContainerViews based on UIStoryboardSegues!'
s.homepage = 'https://github.com/tschob/HSContainerController.git'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Hans Seiffert' => 'hans.seiffert@gmail.com' }
s.source = { :git => 'https://github.com/tschob/HSContainerController.git', :tag => s.version.to_s }
s.platform = :ios
s.ios.deployment_target = '8.0'
s.source_files = 'HSContainerController/**/*.{swift,h}'
s.public_header_files = 'HSContainerController/**/*.h'
s.frameworks = 'UIKit'
end
| #
# Be sure to run `pod lib lint TestLib.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'ContainerController'
s.version = File.read('VERSION')
s.summary = 'Lightweight Swift Framework for iOS which let you replace UIViewController in UIContainerViews based on UIStoryboardSegues!'
s.homepage = 'https://github.com/tschob/ContainerController.git'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Hans Seiffert' => 'hans.seiffert@gmail.com' }
s.source = { :git => 'https://github.com/tschob/ContainerController.git', :tag => s.version.to_s }
s.platform = :ios
s.ios.deployment_target = '8.0'
s.source_files = 'ContainerController/**/*.{swift,h}'
s.public_header_files = 'ContainerController/**/*.h'
s.frameworks = 'UIKit'
end
|
Remove hard-coded date from track upcoming events, and default to entire year in advance | class TrackController < ApplicationController
def index
@upcoming_events = UpcomingEvents.find_all(:date => Date.new(2008, 6), :weeks => 6, :discipline => "Track")
end
def schedule
@events = SingleDayEvent.find_all_by_year(Date.today.year, Discipline[:track]) + MultiDayEvent.find_all_by_year(Date.today.year, Discipline[:track])
end
end | class TrackController < ApplicationController
def index
@upcoming_events = UpcomingEvents.find_all(:weeks => 52, :discipline => "Track")
end
def schedule
@events = SingleDayEvent.find_all_by_year(Date.today.year, Discipline[:track]) + MultiDayEvent.find_all_by_year(Date.today.year, Discipline[:track])
end
end |
Test that project generator creates .gitignore in compiled dir | require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper.rb')
class TestProjectGenerator < MiniTest::Unit::TestCase
def project_dest
File.expand_path(File.join(File.dirname(__FILE__), '../tmp_project'))
end
def teardown
if File.exists?(project_dest)
FileUtils.rm_rf project_dest
end
end
def test_generate_project
Ichiban::ProjectGenerator.new(project_dest).generate
%w(
Capfile
html/index.html
layouts/default.html
assets/css/screen.scss
assets/js/interaction.js
assets/img
assets/misc/readme.txt
data/readme.txt
helpers/readme.txt
models/readme.txt
scripts/readme.txt
compiled/index.html
compiled/css/screen.css
compiled/js/interaction.js
compiled/img
).each do |dest_file|
abs = File.join(project_dest, dest_file)
assert File.exists?(abs), "Expected #{abs} to exist"
end
end
end | require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper.rb')
class TestProjectGenerator < MiniTest::Unit::TestCase
def project_dest
File.expand_path(File.join(File.dirname(__FILE__), '../tmp_project'))
end
def teardown
if File.exists?(project_dest)
FileUtils.rm_rf project_dest
end
end
def test_generate_project
Ichiban::ProjectGenerator.new(project_dest).generate
# Test that each of these files exists:
%w(
Capfile
html/index.html
layouts/default.html
assets/css/screen.scss
assets/js/interaction.js
assets/img
assets/misc/readme.txt
data/readme.txt
helpers/readme.txt
models/readme.txt
scripts/readme.txt
compiled/index.html
compiled/css/screen.css
compiled/js/interaction.js
compiled/img
).each do |dest_file|
abs = File.join(project_dest, dest_file)
assert File.exists?(abs), "Expected #{abs} to exist"
end
end
end |
Send SIGQUIT to sidekiq when exiting. | require 'sidekiq/cli'
options = []
options << ["-r", Dir.pwd + "/test/servers/sidekiq/initializer.rb"]
options << ["-q default -q low -q important"]
options << ["-c 4"]
options << ["-P", Dir.pwd + "/test/tmp/sidekiq_#{Process.pid}.pid"]
cmd_line = ""
options.flatten.each do |x|
cmd_line += " #{x}"
end
::Instana.logger.warn "Booting background Sidekiq worker..."
Thread.new do
system("INSTANA_GEM_TEST=true sidekiq #{cmd_line}")
end
sleep 10
| require 'sidekiq/cli'
options = []
options << ["-r", Dir.pwd + "/test/servers/sidekiq/initializer.rb"]
options << ["-q default -q low -q important"]
options << ["-c 4"]
options << ["-P", Dir.pwd + "/test/tmp/sidekiq_#{Process.pid}.pid"]
cmd_line = ""
options.flatten.each do |x|
cmd_line += " #{x}"
end
::Instana.logger.warn "Booting background Sidekiq worker..."
Thread.new do
begin
system("INSTANA_GEM_TEST=true sidekiq #{cmd_line}")
ensure
# Get and send a kill signal to the sidekiq process
s = File.read(Dir.pwd + "/test/tmp/sidekiq_#{Process.pid}.pid")
Process.kill("QUIT", s.chop.to_i)
end
end
sleep 7
|
Package version is increased from 0.8.0.0 to 0.8.0.1 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
s.version = '0.8.0.0'
s.summary = 'Messaging primitives for Eventide'
s.description = ' '
s.authors = ['The Eventide Project']
s.email = 'opensource@eventide-project.org'
s.homepage = 'https://github.com/eventide-project/messaging'
s.licenses = ['MIT']
s.require_paths = ['lib']
s.files = Dir.glob('{lib}/**/*')
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.3.3'
s.add_runtime_dependency 'evt-event_source'
s.add_development_dependency 'test_bench'
end
| # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
s.version = '0.8.0.1'
s.summary = 'Messaging primitives for Eventide'
s.description = ' '
s.authors = ['The Eventide Project']
s.email = 'opensource@eventide-project.org'
s.homepage = 'https://github.com/eventide-project/messaging'
s.licenses = ['MIT']
s.require_paths = ['lib']
s.files = Dir.glob('{lib}/**/*')
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.3.3'
s.add_runtime_dependency 'evt-event_source'
s.add_development_dependency 'test_bench'
end
|
Package version is increased from 0.29.0.10 to 0.29.0.11 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
s.version = '0.29.0.10'
s.summary = 'Common primitives for platform-specific messaging implementations for Eventide'
s.description = ' '
s.authors = ['The Eventide Project']
s.email = 'opensource@eventide-project.org'
s.homepage = 'https://github.com/eventide-project/messaging'
s.licenses = ['MIT']
s.require_paths = ['lib']
s.files = Dir.glob('{lib}/**/*')
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.4.0'
s.add_runtime_dependency 'evt-message_store'
s.add_development_dependency 'test_bench'
end
| # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'evt-messaging'
s.version = '0.29.0.11'
s.summary = 'Common primitives for platform-specific messaging implementations for Eventide'
s.description = ' '
s.authors = ['The Eventide Project']
s.email = 'opensource@eventide-project.org'
s.homepage = 'https://github.com/eventide-project/messaging'
s.licenses = ['MIT']
s.require_paths = ['lib']
s.files = Dir.glob('{lib}/**/*')
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.4.0'
s.add_runtime_dependency 'evt-message_store'
s.add_development_dependency 'test_bench'
end
|
Drop useless IndexableError (take 2) |
module Dense
VERSION = '1.0.1'
end
require 'raabro'
require 'dense/path'
require 'dense/parser'
require 'dense/errors'
require 'dense/methods'
|
module Dense
VERSION = '1.0.1'
end
require 'raabro'
require 'dense/path'
require 'dense/parser'
require 'dense/methods'
|
Update Balsamiq Mockups to 3.5.5 | cask 'balsamiq-mockups' do
version '3.5.4'
sha256 'ef2ae819ffee8d7fe1641a260c8fa695caaa8719274b8c733baea5f83f953ae1'
url "https://builds.balsamiq.com/mockups-desktop/Balsamiq_Mockups_#{version}.dmg"
name 'Balsamiq Mockups'
homepage 'https://balsamiq.com/'
app "Balsamiq Mockups #{version.major}.app"
zap delete: [
# TODO: expand/glob for "~/Library/Caches/BalsamiqMockups#{version.major}.*",
# TODO: expand/glob for "~/Library/Saved Application State/BalsamiqMockups#{version.major}.*",
],
trash: [
"~/Library/Preferences/BalsamiqMockups#{version.major}",
# TODO: expand/glob for "~/Library/Preferences/BalsamiqMockups#{version.major}.*",
]
end
| cask 'balsamiq-mockups' do
version '3.5.5'
sha256 'b08819effb63fa3361e2286d4e580bc67edf30c16962c34453e191ccbcfc482e'
url "https://builds.balsamiq.com/mockups-desktop/Balsamiq_Mockups_#{version}.dmg"
name 'Balsamiq Mockups'
homepage 'https://balsamiq.com/'
app "Balsamiq Mockups #{version.major}.app"
zap delete: [
# TODO: expand/glob for "~/Library/Caches/BalsamiqMockups#{version.major}.*",
# TODO: expand/glob for "~/Library/Saved Application State/BalsamiqMockups#{version.major}.*",
],
trash: [
"~/Library/Preferences/BalsamiqMockups#{version.major}",
# TODO: expand/glob for "~/Library/Preferences/BalsamiqMockups#{version.major}.*",
]
end
|
Use then_if in events filtering | require 'role_playing'
require 'refinements/method_chain'
require 'paginated_dataset'
require 'date_filtered_dataset'
##
# Filters events by page (offset, limit)
# depending on a requested format.
#
class EventsFiltering
include RolePlaying::Context
using MethodChain
# @param [Sequel::Dataset<Event>]
def initialize(dataset)
@dataset = dataset
end
def call(params: {}, format: :jsonapi)
[DateFilteredDataset, PaginatedDataset].played_by(@dataset) do |dataset|
dataset
.filter_by_date(from: params[:from], to: params[:to])
.then(-> { format != :ical }) { |d| d.paginate(offset: params[:offset], limit: params[:limit]) }
end
end
end
| require 'role_playing'
require 'core_ext/then_if'
require 'paginated_dataset'
require 'date_filtered_dataset'
##
# Filters events by page (offset, limit)
# depending on a requested format.
#
class EventsFiltering
include RolePlaying::Context
using MethodChain
# @param [Sequel::Dataset<Event>]
def initialize(dataset)
@dataset = dataset
end
def call(params: {}, format: :jsonapi)
[DateFilteredDataset, PaginatedDataset].played_by(@dataset) do |dataset|
dataset
.filter_by_date(from: params[:from], to: params[:to])
.then_if(paginate?) { |d| d.paginate(offset: params[:offset], limit: params[:limit]) }
end
end
private
def paginate?
format != :ical
end
end
|
Add test for simple case with only one window. | require 'spec_helper'
describe Winnow::Fingerprinter do
describe '#initialize' do
it 'accepts :guarantee_threshold, :noise_threshold' do
fprinter = Winnow::Fingerprinter.new(
guarantee_threshold: 0, noise_threshold: 1)
expect(fprinter.guarantee_threshold).to eq 0
expect(fprinter.noise_threshold).to eq 1
end
it 'accepts :t and :k' do
fprinter = Winnow::Fingerprinter.new(t: 0, k: 1)
expect(fprinter.guarantee_threshold).to eq 0
expect(fprinter.noise_threshold).to eq 1
end
end
describe '#fingerprints' do
it 'hashes strings to get keys' do
# if t = k = 1, then each character will become a fingerprint
fprinter = Winnow::Fingerprinter.new(t: 1, k: 1)
fprints = fprinter.fingerprints("abcdefg")
hashes = Set.new(('a'..'g').map(&:hash))
fprint_hashes = Set.new(fprints.map(&:value))
expect(fprint_hashes).to eq hashes
end
end
end
| require 'spec_helper'
describe Winnow::Fingerprinter do
describe '#initialize' do
it 'accepts :guarantee_threshold, :noise_threshold' do
fprinter = Winnow::Fingerprinter.new(
guarantee_threshold: 0, noise_threshold: 1)
expect(fprinter.guarantee_threshold).to eq 0
expect(fprinter.noise_threshold).to eq 1
end
it 'accepts :t and :k' do
fprinter = Winnow::Fingerprinter.new(t: 0, k: 1)
expect(fprinter.guarantee_threshold).to eq 0
expect(fprinter.noise_threshold).to eq 1
end
end
describe '#fingerprints' do
it 'hashes strings to get keys' do
# if t = k = 1, then each character will become a fingerprint
fprinter = Winnow::Fingerprinter.new(t: 1, k: 1)
fprints = fprinter.fingerprints("abcdefg")
hashes = Set.new(('a'..'g').map(&:hash))
fprint_hashes = Set.new(fprints.map(&:value))
expect(fprint_hashes).to eq hashes
end
it 'chooses the smallest hash per window' do
# window size = t - k + 1 = 2 ; for a two-char string, the sole
# fingerprint should just be from the char with the smallest hash value
fprinter = Winnow::Fingerprinter.new(t: 2, k: 1)
fprints = fprinter.fingerprints("ab")
expect(fprints.length).to eq 1
expect(fprints.first.value).to eq ["a", "b"].map(&:hash).min
end
end
end
|
Fix the URLs of APNS Pusher | cask :v1 => 'apns-pusher' do
version '2.3'
sha256 '6aa54050bea8603b45e6737bf2cc6997180b1a58f1d02095f5141176a1335205'
url "https://github.com/blommegard/APNS-Pusher/releases/download/v#{version}/APNS.Pusher.app.zip"
appcast 'https://github.com/blommegard/APNS-Pusher/releases.atom'
name 'APNS Pusher'
homepage 'https://github.com/blommegard/APNS-Pusher'
license :mit
app 'APNS Pusher.app'
end
| cask :v1 => 'apns-pusher' do
version '2.3'
sha256 '6aa54050bea8603b45e6737bf2cc6997180b1a58f1d02095f5141176a1335205'
url "https://github.com/KnuffApp/APNS-Pusher/releases/download/v#{version}/APNS.Pusher.app.zip"
appcast 'https://github.com/KnuffApp/APNS-Pusher/releases.atom'
name 'APNS Pusher'
homepage 'https://github.com/KnuffApp/APNS-Pusher'
license :mit
app 'APNS Pusher.app'
end
|
Test for existence of purge_all task | require 'spec_helper'
describe Capistrano::Fastly do
pending "YOOOOOOO!"
end
| require 'spec_helper'
describe Capistrano::Fastly do
before do
@configuration = Capistrano::Configuration.new
Capistrano::Fastly.load_into(@configuration)
end
it 'provides fastly:purge_all' do
@configuration.find_task('fastly:purge_all').should_not == nil
end
end
|
Fix missing constant bug under Ruby 1.8.7 | require 'aruba-doubles'
World(ArubaDoubles)
Before do
Double.setup
end
After do
Double.teardown
end
Given /^I double `([^`]*)`$/ do |cmd|
double_cmd(cmd)
end
Given /^I double `([^`]*)` with "([^"]*)"$/ do |cmd,stdout|
double_cmd(cmd, :stdout => stdout)
end
Given /^I double `([^`]*)` with stdout:$/ do |cmd,stdout|
double_cmd(cmd, :stdout => stdout)
end
Given /^I double `([^`]*)` with exit status (\d+) and stdout:$/ do |cmd, exit_status, stdout|
double_cmd(cmd, :stdout => stdout, :exit_status => exit_status.to_i)
end
Given /^I double `([^`]*)` with stderr:$/ do |cmd,stderr|
double_cmd(cmd, :stderr => stderr)
end
Given /^I double `([^`]*)` with exit status (\d+) and stderr:$/ do |cmd, exit_status, stderr|
double_cmd(cmd, :stderr => stderr, :exit_status => exit_status.to_i)
end
Given /^I double `([^`]*)` with exit status (\d+)$/ do |cmd, exit_status|
double_cmd(cmd, :exit_status => exit_status.to_i)
end
| require 'aruba-doubles'
World(ArubaDoubles)
Before do
ArubaDoubles::Double.setup
end
After do
ArubaDoubles::Double.teardown
end
Given /^I double `([^`]*)`$/ do |cmd|
double_cmd(cmd)
end
Given /^I double `([^`]*)` with "([^"]*)"$/ do |cmd,stdout|
double_cmd(cmd, :stdout => stdout)
end
Given /^I double `([^`]*)` with stdout:$/ do |cmd,stdout|
double_cmd(cmd, :stdout => stdout)
end
Given /^I double `([^`]*)` with exit status (\d+) and stdout:$/ do |cmd, exit_status, stdout|
double_cmd(cmd, :stdout => stdout, :exit_status => exit_status.to_i)
end
Given /^I double `([^`]*)` with stderr:$/ do |cmd,stderr|
double_cmd(cmd, :stderr => stderr)
end
Given /^I double `([^`]*)` with exit status (\d+) and stderr:$/ do |cmd, exit_status, stderr|
double_cmd(cmd, :stderr => stderr, :exit_status => exit_status.to_i)
end
Given /^I double `([^`]*)` with exit status (\d+)$/ do |cmd, exit_status|
double_cmd(cmd, :exit_status => exit_status.to_i)
end
|
Add query new path, comment out bing_new path - because in modal | class QueriesController < ApplicationController
# include translateYo::Commentable #may need to be rewritten to work
#before_action :language
def index
@queries = language.queries.all
#.where(language_id: params[:language_id])
end
def show
@query = Query.find(params[:id])
@language = @query.language
end
def create
@query = language.queries.new(query_params)
if @query.save
redirect_to language_path(@language)
else
render 'languages/show'
end
end
def bing_create
text_to_translate = params[:query][:english]
to_text = Language.find(params[:language_id])
@query = language.queries.new(query_params)
@query.other = API.call_api(text_to_translate, to_text)
if @query.save
redirect_to language_path(@language)
else
render 'languages/show'
end
end
private
def query_params
params.require(:query).permit(:title, :description, :english, :other)
end
def language
@language ||= Language.find(params[:language_id])
end
end
| class QueriesController < ApplicationController
# include translateYo::Commentable #may need to be rewritten to work
#before_action :language
def index
@queries = language.queries.all
#.where(language_id: params[:language_id])
end
def show
@query = Query.find(params[:id])
@language = @query.language
end
def new
@query = language.queries.new
end
def create
@query = language.queries.new(query_params)
if @query.save
redirect_to language_path(@language)
else
render 'languages/show'
end
end
# def bing_new
# @query = language.queries.new
# end
def bing_create
text_to_translate = params[:query][:english]
to_text = Language.find(params[:language_id])
@query = language.queries.new(query_params)
@query.other = API.call_api(text_to_translate, to_text)
if @query.save
redirect_to language_path(@language)
else
render 'languages/show'
end
end
private
def query_params
params.require(:query).permit(:title, :description, :english, :other)
end
def language
@language ||= Language.find(params[:language_id])
end
end
|
Reset gem specs for testing. | # require bezel
require 'bezel'
# use a dummy Gem location for this example
ENV['GEM_HOME'] = File.expand_path('../fixtures', File.dirname(__FILE__))
#p Gem::Specification.all_names
#Gem.path.unshift(File.expand_path('../fixtures', File.dirname(__FILE__)))
#puts "Gem path added: " + File.expand_path('fixtures', File.dirname(__FILE__))
| # Use a dummy Gem location for this example.
dummy_gem_home = File.expand_path('../fixtures', File.dirname(__FILE__))
ENV['GEM_HOME'] = dummy_gem_home
Gem.path.unshift(dummy_gem_home)
Gem::Specification.reset
#p Gem::Specification.all_names
#puts "Gem path added: #{dummy_gem_home}"
# Require Bezel
require 'bezel'
|
Whitelist attributes for hosting accounts | class HostingAccount < ActiveRecord::Base
belongs_to :domain, touch: true
end
| class HostingAccount < ActiveRecord::Base
attr_accessible :annual_fee, :backed_up_on, :backup_cycle, :domain_id,
:ftp_host, :host_name, :started_on, :username, :password
belongs_to :domain, touch: true
end
|
Add a test for RuntimeErrors. | require File.expand_path("../lib/redic", File.dirname(__FILE__))
setup do
Redic.new
end
test "url" do |c|
assert_equal "redis://127.0.0.1:6379", c.url
end
test "normal commands" do |c|
c.call("SET", "foo", "bar")
assert_equal "bar", c.call("GET", "foo")
end
test "pipelining" do |c|
c.write("SET", "foo", "bar")
c.write("GET", "foo")
assert_equal ["OK", "bar"], c.run
end
test "multi/exec" do |c|
c.write("MULTI")
c.write("SET", "foo", "bar")
c.write("EXEC")
assert_equal ["OK", "QUEUED", ["OK"]], c.run
end
| require File.expand_path("../lib/redic", File.dirname(__FILE__))
setup do
Redic.new
end
test "url" do |c|
assert_equal "redis://127.0.0.1:6379", c.url
end
test "normal commands" do |c|
c.call("SET", "foo", "bar")
assert_equal "bar", c.call("GET", "foo")
end
test "pipelining" do |c|
c.write("SET", "foo", "bar")
c.write("GET", "foo")
assert_equal ["OK", "bar"], c.run
end
test "multi/exec" do |c|
c.write("MULTI")
c.write("SET", "foo", "bar")
c.write("EXEC")
assert_equal ["OK", "QUEUED", ["OK"]], c.run
end
test "runtime errors" do |c|
assert_raise RuntimeError do
c.call("KABLAMMO")
end
end
|
Update the gem version to 1.0.0 | spec = Gem::Specification.new do |s|
s.name = 'deferred_job'
s.authors = ['John Crepezzi', 'Aubrey Holland']
s.description = 'Deferred Jobs'
s.email = 'aubrey@brewster.com'
s.add_development_dependency 'rspec'
s.add_development_dependency 'activesupport'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'sidekiq'
s.add_development_dependency 'redis'
s.add_dependency 'multi_json'
s.files = Dir['lib/**/*.rb'] + ['README.md']
s.homepage = 'http://github.com/brewster/deferred_job'
s.platform = Gem::Platform::RUBY
s.require_paths = ['lib']
s.summary = 'Deferred job library for Sidekiq or generic classes'
s.test_files = Dir.glob('spec/*.rb')
s.version = '0.1.1' # TODO
end
| spec = Gem::Specification.new do |s|
s.name = 'deferred_job'
s.authors = ['John Crepezzi', 'Aubrey Holland']
s.description = 'Deferred Jobs'
s.email = 'aubrey@brewster.com'
s.add_development_dependency 'rspec'
s.add_development_dependency 'activesupport'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'sidekiq'
s.add_development_dependency 'redis'
s.add_dependency 'multi_json'
s.files = Dir['lib/**/*.rb'] + ['README.md']
s.homepage = 'http://github.com/brewster/deferred_job'
s.platform = Gem::Platform::RUBY
s.require_paths = ['lib']
s.summary = 'Deferred job library for Sidekiq or generic classes'
s.test_files = Dir.glob('spec/*.rb')
s.version = '1.0.0'
end
|
Allow only strings for assume role polciy | require 'chef/provisioning/aws_driver/aws_resource'
#
# An AWS IAM role, specifying set of policies for acessing other AWS services.
#
# `name` is unique for an AWS account.
#
# API documentation for the AWS Ruby SDK for IAM roles (and the object returned from `aws_object`) can be found here:
#
# - http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM.html
#
class Chef::Resource::AwsIamRole < Chef::Provisioning::AWSDriver::AWSResource
aws_sdk_type ::Aws::IAM::Role, id: :name
#
# The name of the role to create.
#
attribute :name, kind_of: String, name_attribute: true
#
# The path to the role. For more information about paths, see http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html
#
attribute :path, kind_of: String
#
# The policy that grants an entity permission to assume the role.
#
attribute :assume_role_policy_document, kind_of: [ String, Array ], required: true
def aws_object
driver.iam_resource.role(name).load
rescue ::Aws::IAM::Errors::NoSuchEntity
nil
end
end
| require 'chef/provisioning/aws_driver/aws_resource'
#
# An AWS IAM role, specifying set of policies for acessing other AWS services.
#
# `name` is unique for an AWS account.
#
# API documentation for the AWS Ruby SDK for IAM roles (and the object returned from `aws_object`) can be found here:
#
# - http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM.html
#
class Chef::Resource::AwsIamRole < Chef::Provisioning::AWSDriver::AWSResource
aws_sdk_type ::Aws::IAM::Role, id: :name
#
# The name of the role to create.
#
attribute :name, kind_of: String, name_attribute: true
#
# The path to the role. For more information about paths, see http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html
#
attribute :path, kind_of: String
#
# The policy that grants an entity permission to assume the role.
#
attribute :assume_role_policy_document, kind_of: String, required: true
def aws_object
driver.iam_resource.role(name).load
rescue ::Aws::IAM::Errors::NoSuchEntity
nil
end
end
|
Update cocoapod version to 1.1.0 | Pod::Spec.new do |s|
s.name = "ScrollableGraphView"
s.version = "1.0.1"
s.summary = "Scrollable graph view for iOS"
s.description = "An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift."
s.homepage = "https://github.com/philackm/Scrollable-GraphView"
s.license = 'MIT'
s.author = { "philackm" => "philackm@icloud.com" }
s.source = { :git => "https://github.com/philackm/Scrollable-GraphView.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
# If more than one source file: https://guides.cocoapods.org/syntax/podspec.html#source_files
s.source_files = 'Classes/ScrollableGraphView.swift'
end
| Pod::Spec.new do |s|
s.name = "ScrollableGraphView"
s.version = "1.1.0"
s.summary = "Scrollable graph view for iOS"
s.description = "An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift."
s.homepage = "https://github.com/philackm/Scrollable-GraphView"
s.license = 'MIT'
s.author = { "philackm" => "philackm@icloud.com" }
s.source = { :git => "https://github.com/philackm/Scrollable-GraphView.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
# If more than one source file: https://guides.cocoapods.org/syntax/podspec.html#source_files
s.source_files = 'Classes/ScrollableGraphView.swift'
end
|
Add a file for misc tests, starting with test_empty_repository to try to reproduce an issue reported by a user on the mailing list | #!/usr/bin/ruby -w
#
# Test miscellaneous items that don't fit elsewhere
#
require "./#{File.dirname(__FILE__)}/etchtest"
require 'webrick'
class EtchMiscTests < Test::Unit::TestCase
include EtchTests
def setup
# Generate a file to use as our etch target/destination
@targetfile = released_tempfile
#puts "Using #{@targetfile} as target file"
# Generate a directory for our test repository
@repodir = initialize_repository
@server = get_server(@repodir)
# Create a directory to use as a working directory for the client
@testroot = tempdir
#puts "Using #{@testroot} as client working directory"
end
def test_empty_repository
# Does etch behave properly if the repository is empty? I.e. no source or
# commands directories.
testname = 'empty repository'
run_etch(@server, @testroot, :testname => testname)
end
def teardown
remove_repository(@repodir)
FileUtils.rm_rf(@testroot)
FileUtils.rm_rf(@targetfile)
end
end
| |
Update Delayed Job and RSpec dependencies in gemspec. | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'delayed_job_data_mapper'
s.summary = 'DataMapper backend for delayed_job'
s.version = '1.0.0.rc'
s.authors = 'Brandon Keepers'
s.date = Date.today.to_s
s.email = 'brandon@collectiveidea.com'
s.extra_rdoc_files = ["LICENSE", "README.md"]
s.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE README.md]
s.homepage = 'http://github.com/collectiveidea/delayed_job_data_mapper'
s.rdoc_options = ['--charset=UTF-8']
s.require_paths = ['lib']
s.test_files = Dir.glob('spec/**/*')
s.add_runtime_dependency 'dm-core'
s.add_runtime_dependency 'dm-observer'
s.add_runtime_dependency 'dm-aggregates'
s.add_runtime_dependency 'delayed_job', '~> 2.1'
s.add_development_dependency 'rspec', '>= 1.2.9'
end
| # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'delayed_job_data_mapper'
s.summary = 'DataMapper backend for delayed_job'
s.version = '1.0.0.rc'
s.authors = 'Brandon Keepers'
s.date = Date.today.to_s
s.email = 'brandon@collectiveidea.com'
s.extra_rdoc_files = ["LICENSE", "README.md"]
s.files = Dir.glob("{lib,spec}/**/*") + %w[LICENSE README.md]
s.homepage = 'http://github.com/collectiveidea/delayed_job_data_mapper'
s.rdoc_options = ['--charset=UTF-8']
s.require_paths = ['lib']
s.test_files = Dir.glob('spec/**/*')
s.add_runtime_dependency 'dm-core'
s.add_runtime_dependency 'dm-observer'
s.add_runtime_dependency 'dm-aggregates'
s.add_runtime_dependency 'delayed_job', '3.0.0.pre'
s.add_development_dependency 'rspec'
end
|
Add SAML to list of social_provider | module OauthHelper
def ldap_enabled?
Gitlab.config.ldap.enabled
end
def default_providers
[:twitter, :github, :gitlab, :bitbucket, :google_oauth2, :ldap]
end
def enabled_oauth_providers
Devise.omniauth_providers
end
def enabled_social_providers
enabled_oauth_providers.select do |name|
[:twitter, :gitlab, :github, :bitbucket, :google_oauth2].include?(name.to_sym)
end
end
def additional_providers
enabled_oauth_providers.reject{|provider| provider.to_s.starts_with?('ldap')}
end
def oauth_image_tag(provider, size = 64)
file_name = "#{provider.to_s.split('_').first}_#{size}.png"
image_tag(image_path("authbuttons/#{file_name}"), alt: "Sign in with #{provider.to_s.titleize}")
end
def oauth_active?(provider)
current_user.identities.exists?(provider: provider.to_s)
end
extend self
end
| module OauthHelper
def ldap_enabled?
Gitlab.config.ldap.enabled
end
def default_providers
[:twitter, :github, :gitlab, :bitbucket, :google_oauth2, :ldap]
end
def enabled_oauth_providers
Devise.omniauth_providers
end
def enabled_social_providers
enabled_oauth_providers.select do |name|
[:saml, :twitter, :gitlab, :github, :bitbucket, :google_oauth2].include?(name.to_sym)
end
end
def additional_providers
enabled_oauth_providers.reject{|provider| provider.to_s.starts_with?('ldap')}
end
def oauth_image_tag(provider, size = 64)
file_name = "#{provider.to_s.split('_').first}_#{size}.png"
image_tag(image_path("authbuttons/#{file_name}"), alt: "Sign in with #{provider.to_s.titleize}")
end
def oauth_active?(provider)
current_user.identities.exists?(provider: provider.to_s)
end
extend self
end
|
Fix insane N+1 in Package | # Extends Spree's Package implementation to skip shipping methods that are not
# valid for OFN.
#
# It requires the following configuration in config/initializers/spree.rb:
#
# Spree.config do |config|
# ...
# config.package_factory = Stock::Package
# end
#
module Stock
class Package < Spree::Stock::Package
# Returns all existing shipping categories.
# It does not filter by the shipping categories of the products in the order.
# It allows checkout of products with categories that are not the shipping methods categories
# It disables the matching of product shipping category with shipping method's category
#
# @return [Array<Spree::ShippingCategory>]
def shipping_categories
Spree::ShippingCategory.all
end
# Skips the methods that are not used by the order's distributor
#
# @return [Array<Spree::ShippingMethod>]
def shipping_methods
super.delete_if do |shipping_method|
!ships_with?(order.distributor, shipping_method)
end
end
private
# Checks whether the given distributor provides the specified shipping method
#
# @param distributor [Spree::Enterprise]
# @param shipping_method [Spree::ShippingMethod]
# @return [Boolean]
def ships_with?(distributor, shipping_method)
distributor.shipping_methods.include?(shipping_method)
end
end
end
| # Extends Spree's Package implementation to skip shipping methods that are not
# valid for OFN.
#
# It requires the following configuration in config/initializers/spree.rb:
#
# Spree.config do |config|
# ...
# config.package_factory = Stock::Package
# end
#
module Stock
class Package < Spree::Stock::Package
# Returns all existing shipping categories.
# It does not filter by the shipping categories of the products in the order.
# It allows checkout of products with categories that are not the shipping methods categories
# It disables the matching of product shipping category with shipping method's category
#
# @return [Array<Spree::ShippingCategory>]
def shipping_categories
Spree::ShippingCategory.all
end
# Skips the methods that are not used by the order's distributor
#
# @return [Array<Spree::ShippingMethod>]
def shipping_methods
available_shipping_methods = super.to_a
available_shipping_methods.delete_if do |shipping_method|
!ships_with?(order.distributor.shipping_methods.to_a, shipping_method)
end
end
private
# Checks whether the given distributor provides the specified shipping method
#
# @param shipping_methods [Array<Spree::ShippingMethod>]
# @param shipping_method [Spree::ShippingMethod]
# @return [Boolean]
def ships_with?(shipping_methods, shipping_method)
shipping_methods.include?(shipping_method)
end
end
end
|
Set the version number to 1.0.0-beta.2. | Pod::Spec.new do |s|
s.name = "Swinject"
s.version = "1.0.0-beta.1"
s.summary = "Dependency injection framework for Swift"
s.description = <<-DESC
Swinject is a dependency injection framework for Swift, to manage the dependencies of types in your system.
DESC
s.homepage = "https://github.com/Swinject/Swinject"
s.license = 'MIT'
s.author = 'Swinject Contributors'
s.source = { :git => "https://github.com/Swinject/Swinject.git", :tag => s.version.to_s }
shared_files = 'Swinject/*.swift'
s.ios.source_files = shared_files, 'Swinject/iOS-tvOS/*.{swift,h,m}'
s.osx.source_files = shared_files, 'Swinject/OSX/*.{swift,h,m}'
s.watchos.source_files = shared_files, 'Swinject/watchOS/*.{swift,h,m}'
s.tvos.source_files = shared_files, 'Swinject/iOS-tvOS/*.{swift,h,m}'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.requires_arc = true
end
| Pod::Spec.new do |s|
s.name = "Swinject"
s.version = "1.0.0-beta.2"
s.summary = "Dependency injection framework for Swift"
s.description = <<-DESC
Swinject is a dependency injection framework for Swift, to manage the dependencies of types in your system.
DESC
s.homepage = "https://github.com/Swinject/Swinject"
s.license = 'MIT'
s.author = 'Swinject Contributors'
s.source = { :git => "https://github.com/Swinject/Swinject.git", :tag => s.version.to_s }
shared_files = 'Swinject/*.swift'
s.ios.source_files = shared_files, 'Swinject/iOS-tvOS/*.{swift,h,m}'
s.osx.source_files = shared_files, 'Swinject/OSX/*.{swift,h,m}'
s.watchos.source_files = shared_files, 'Swinject/watchOS/*.{swift,h,m}'
s.tvos.source_files = shared_files, 'Swinject/iOS-tvOS/*.{swift,h,m}'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.requires_arc = true
end
|
Use from option from configuration | require 'cerberus/publisher/base'
class Cerberus::Publisher::Gmailer < Cerberus::Publisher::Base
def self.publish(state, manager, options)
require 'gmailer'
subject, body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
gopts = options[:publisher, :gmailer]
recipients = options[:publisher, :gmailer, :recipients]
GMailer.connect(gopts) do |g|
success = g.send(:to => recipients, :subject => subject, :body => body)
raise 'Unable to send mail using Gmailer' unless success
end
end
end | require 'cerberus/publisher/base'
class Cerberus::Publisher::Gmailer < Cerberus::Publisher::Base
def self.publish(state, manager, options)
require 'gmailer'
subject, body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
gopts = options[:publisher, :gmailer]
recipients = gopts[:recipients]
GMailer.connect(gopts) do |g|
success = g.send(:to => recipients, :subject => subject, :body => body, :from => gopts[:recipients])
raise 'Unable to send mail using Gmailer' unless success
end
end
end |
Update gem dependencies and versions Nokogiri is added since it is called directly ActiveSupport version is relaxed since called methods were introduced in 1.0.0 Builder and Nokogiri versions are relaxed to the minimum of what Savon requires | $:.push File.expand_path('../lib', __FILE__)
require 'isbm_adaptor/version'
Gem::Specification.new do |s|
s.name = 'isbm_adaptor'
s.version = IsbmAdaptor::VERSION
s.authors = ['Assetricity']
s.email = ['info@assetricity.com']
s.homepage = 'https://github.com/assetricity/isbm_adaptor'
s.summary = 'ISBM Adaptor provides a Ruby API for the OpenO&M ISBM specification'
s.license = 'MIT'
s.files = Dir.glob('lib/**/*') + Dir.glob('wsdls/*') + %w(LICENSE README.md)
s.add_development_dependency 'rake', '~> 10.1.0'
s.add_development_dependency 'rspec', '~> 2.14.0'
s.add_development_dependency 'vcr', '~> 2.5.0'
s.add_development_dependency 'webmock', '~> 1.13.0'
s.add_runtime_dependency 'activesupport', '>= 3.0.0'
s.add_runtime_dependency 'builder', '>= 3.0.0'
s.add_runtime_dependency 'savon', '>= 2.0.0'
end
| $:.push File.expand_path('../lib', __FILE__)
require 'isbm_adaptor/version'
Gem::Specification.new do |s|
s.name = 'isbm_adaptor'
s.version = IsbmAdaptor::VERSION
s.authors = ['Assetricity']
s.email = ['info@assetricity.com']
s.homepage = 'https://github.com/assetricity/isbm_adaptor'
s.summary = 'ISBM Adaptor provides a Ruby API for the OpenO&M ISBM specification'
s.license = 'MIT'
s.files = Dir.glob('lib/**/*') + Dir.glob('wsdls/*') + %w(LICENSE README.md)
s.add_development_dependency 'rake', '~> 10.1.0'
s.add_development_dependency 'rspec', '~> 2.14.0'
s.add_development_dependency 'vcr', '~> 2.8.0'
s.add_development_dependency 'webmock', '~> 1.16.0'
s.add_runtime_dependency 'activesupport', '>= 1.0.0'
s.add_runtime_dependency 'builder', '>= 2.1.2'
s.add_runtime_dependency 'nokogiri', '>= 1.4.0'
s.add_runtime_dependency 'savon', '>= 2.0.0'
end
|
Use a mixin/concern for configuring parameters for DeviseController | Zangetsu::Application.config.generators do |g|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
# don't generate quite so much cruft when scaffolding
g.javascripts false
g.stylesheets false
g.helper false
g.jbuilder false
# don't go overboard with generated specs either
g.test_framework :rspec,
:helper_specs => false,
:request_specs => false,
:routing_specs => false,
:view_specs => false
g.scaffold_controller = 'scaffold_controller'
end
require "devise_controller"
class DeviseController
before_filter :configure_permitted_parameters
hide_action :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
end
end
| Zangetsu::Application.config.generators do |g|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
# don't generate quite so much cruft when scaffolding
g.javascripts false
g.stylesheets false
g.helper false
g.jbuilder false
# don't go overboard with generated specs either
g.test_framework :rspec,
:helper_specs => false,
:request_specs => false,
:routing_specs => false,
:view_specs => false
g.scaffold_controller = 'scaffold_controller'
end
module Zangetsu
module Devise
module PermittedParameters
# extends ................................................................
extend ActiveSupport::Concern
# includes ...............................................................
# constants ..............................................................
# additional config ......................................................
included do
before_filter :configure_permitted_parameters
end
# class methods ..........................................................
# helper methods .........................................................
# protected instance methods .............................................
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
end
# private instance methods ...............................................
end
end
end
DeviseController.send :include, Zangetsu::Devise::PermittedParameters
|
Revert rand methods with deprecate warning | module Faker
module ArrayUtils
def self.const_array(argument)
array = argument.is_a?(Array) ? argument : argument.to_a
array.extend ArrayUtils
freeze_all(array)
end
def self.random_pick(array, n)
indexes = (0...array.length).sort_by{Kernel.rand}[0...n]
indexes.map { |n| array[n].dup }
end
def self.freeze_all(array)
array.each { |e| e.freeze }
array.freeze
array
end
def self.shuffle(array)
array.sort_by{Kernel.rand}
end
def random_pick(n)
ArrayUtils.random_pick(self, n)
end
def freeze_all
ArrayUtils.freeze_all(self)
end
def shuffle
ArrayUtils.shuffle(self)
end
end
end
| module Faker
module ArrayUtils
def self.const_array(argument)
array = argument.is_a?(Array) ? argument : argument.to_a
array.extend ArrayUtils
freeze_all(array)
end
def self.random_pick(array, n)
indexes = (0...array.length).sort_by{Kernel.rand}[0...n]
indexes.map { |n| array[n].dup }
end
def self.rand(array)
warn '[ArrayUtils.rand] is deprecated. Please use the Array#sample method'
array.sample
end
def self.freeze_all(array)
array.each { |e| e.freeze }
array.freeze
array
end
def self.shuffle(array)
array.sort_by{Kernel.rand}
end
def random_pick(n)
ArrayUtils.random_pick(self, n)
end
def rand
warn '[ArrayUtils#rand] is deprecated. Please use the Array#sample method'
sample
end
def freeze_all
ArrayUtils.freeze_all(self)
end
def shuffle
ArrayUtils.shuffle(self)
end
end
end
|
Load all plugins by default | module Refinery
module Redactor
class Engine < ::Rails::Engine
include Refinery::Engine
isolate_namespace Refinery
engine_name :refinery_redactor
# set the manifests and assets to be precompiled
config.to_prepare do
Rails.application.config.assets.precompile += %w(
refinery-redactor/index.css
refinery-redactor/plugins.js
refinery-redactor/index.js
)
end
before_inclusion do
Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = "refinerycms_redactor"
plugin.hide_from_menu = true
plugin.menu_match = %r{refinery/redactor}
end
end
config.after_initialize do
Refinery.register_engine Refinery::Redactor
end
after_inclusion do
%w(refinery-redactor/index).each do |stylesheet|
Refinery::Core.config.register_visual_editor_stylesheet stylesheet
end
%W(refinery-redactor/index refinery-redactor/plugins).each do |javascript|
Refinery::Core.config.register_visual_editor_javascript javascript
end
end
end
end
end
| module Refinery
module Redactor
class Engine < ::Rails::Engine
include Refinery::Engine
isolate_namespace Refinery
engine_name :refinery_redactor
# set the manifests and assets to be precompiled
config.to_prepare do
Rails.application.config.assets.precompile += %w(
refinery-redactor/index.css
refinery-redactor/plugins.css
refinery-redactor/plugins.js
refinery-redactor/index.js
)
end
before_inclusion do
Refinery::Plugin.register do |plugin|
plugin.pathname = root
plugin.name = "refinerycms_redactor"
plugin.hide_from_menu = true
plugin.menu_match = %r{refinery/redactor}
end
end
config.after_initialize do
Refinery.register_engine Refinery::Redactor
end
after_inclusion do
%w(refinery-redactor/plugins refinery-redactor/index).each do |stylesheet|
Refinery::Core.config.register_visual_editor_stylesheet stylesheet
end
%W(refinery-redactor/plugins refinery-redactor/index).each do |javascript|
Refinery::Core.config.register_visual_editor_javascript javascript
end
end
end
end
end
|
Fix test for opal 0.8 | require 'spec_helper'
if opal?
describe 'Refs callback' do
before do
stub_const 'Foo', Class.new
Foo.class_eval do
include React::Component
end
end
it "is invoked with the actual Ruby instance" do
stub_const 'Bar', Class.new
Bar.class_eval do
include React::Component
def render
React.create_element('div')
end
end
Foo.class_eval do
attr_accessor :my_bar
def render
React.create_element(Bar, ref: method(:my_bar=).to_proc)
end
end
element = React.create_element(Foo)
instance = React::Test::Utils.render_into_document(element)
expect(instance.my_bar).to be_a(Bar)
end
it "is invoked with the actual DOM node" do
Foo.class_eval do
attr_accessor :my_div
def render
React.create_element('div', ref: method(:my_div=).to_proc)
end
end
element = React.create_element(Foo)
instance = React::Test::Utils.render_into_document(element)
expect(`#{instance.my_div}.nodeType`).to eq(1)
end
end
end
| require 'spec_helper'
if opal?
describe 'Refs callback' do
before do
stub_const 'Foo', Class.new
Foo.class_eval do
include React::Component
end
end
it "is invoked with the actual Ruby instance" do
stub_const 'Bar', Class.new
Bar.class_eval do
include React::Component
def render
React.create_element('div')
end
end
Foo.class_eval do
def my_bar=(bar)
$bar = bar
end
def render
React.create_element(Bar, ref: method(:my_bar=).to_proc)
end
end
element = React.create_element(Foo)
React::Test::Utils.render_into_document(element)
expect($bar).to be_a(Bar)
$bar = nil
end
it "is invoked with the actual DOM node" do
Foo.class_eval do
def my_div=(div)
$div = div
end
def render
React.create_element('div', ref: method(:my_div=).to_proc)
end
end
element = React.create_element(Foo)
React::Test::Utils.render_into_document(element)
expect(`#{$div}.nodeType`).to eq(1)
$div = nil
end
end
end
|
Remove explicit dependencies on bundler/rake | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'workflows/version'
Gem::Specification.new do |spec|
spec.name = "workflows"
spec.version = Workflows::VERSION
spec.authors = ["Brenton Annan"]
spec.email = ["brentonannan@brentonannan.com"]
spec.summary = %q{Modules to make working with workflows and services simple and robust}
spec.homepage = "https://github.com/blake-education/workflows"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.2.0"
end
| # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'workflows/version'
Gem::Specification.new do |spec|
spec.name = "workflows"
spec.version = Workflows::VERSION
spec.authors = ["Brenton Annan"]
spec.email = ["brentonannan@brentonannan.com"]
spec.summary = %q{Modules to make working with workflows and services simple and robust}
spec.homepage = "https://github.com/blake-education/workflows"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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 "rspec", "~> 3.2.0"
end
|
Add year to Event date | class Event < ActiveRecord::Base
belongs_to :campus
belongs_to :user
validates :campus, presence: true
default_scope {order(happens_on: :asc)}
has_attached_file :uploaded_file, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '300x300>'
}
validates_attachment_content_type :uploaded_file, :content_type => /\Aimage\/.*\Z/
def event_date
happens_on.strftime "%a, %b %e"
end
def event_time
happens_on.strftime "%l:%M %p"
end
end
| class Event < ActiveRecord::Base
belongs_to :campus
belongs_to :user
validates :campus, presence: true
default_scope {order(happens_on: :asc)}
has_attached_file :uploaded_file, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '300x300>'
}
validates_attachment_content_type :uploaded_file, :content_type => /\Aimage\/.*\Z/
def event_date
happens_on.strftime "%a, %b %e, %Y"
end
def event_time
happens_on.strftime "%l:%M %p"
end
end
|
Fix test now that main section is a main element | require 'spec_helper'
describe "Start page" do
specify "Inspecting the start page" do
visit "/#{APP_SLUG}"
within 'section#content' do
within 'header' do
page.should have_content("Business finance and support finder")
page.should have_content("Quick answer")
end
within 'article[role=article]' do
within 'section.intro' do
page.should have_link("Get started", :href => "/#{APP_SLUG}/sectors")
end
end
page.should have_selector(".article-container #test-report_a_problem")
end
page.should have_selector("#test-related")
end
end
| require 'spec_helper'
describe "Start page" do
specify "Inspecting the start page" do
visit "/#{APP_SLUG}"
within '#content' do
within 'header' do
page.should have_content("Business finance and support finder")
page.should have_content("Quick answer")
end
within 'article[role=article]' do
within 'section.intro' do
page.should have_link("Get started", :href => "/#{APP_SLUG}/sectors")
end
end
page.should have_selector(".article-container #test-report_a_problem")
end
page.should have_selector("#test-related")
end
end
|
Adjust python detection for specs | require 'open3'
module PythonHelper
class << self
attr_accessor :python_path
end
def detect_python
stdout, stderr, status = Open3.capture3('command -v python')
if status.exitstatus == 0
PythonHelper.python_path = stdout.chomp
else
warn('Python not found on $PATH, disabling tests using python')
end
end
def exec_python(program)
stdout, stderr, status = Open3.capture3("python -c '#{program}'")
if status.exitstatus != 0
err = [
"Execution of python program '#{program}' failed!",
"STDOUT: #{stdout}",
"STDERR: #{stderr}"
].join("\n")
raise err
end
stdout.chomp
end
end
| require 'open3'
module PythonHelper
class << self
attr_accessor :python_path
end
def detect_python
stdout, stderr, status = Open3.capture3(%q{/usr/bin/env bash -c 'command -v python'})
if status.exitstatus == 0
PythonHelper.python_path = stdout.chomp
else
warn('Python not found on $PATH, disabling tests using python')
end
end
def exec_python(program)
stdout, stderr, status = Open3.capture3("python -c '#{program}'")
if status.exitstatus != 0
err = [
"Execution of python program '#{program}' failed!",
"STDOUT: #{stdout}",
"STDERR: #{stderr}"
].join("\n")
raise err
end
stdout.chomp
end
end
|
Create rake tasks for BEC import | require 'csv'
def if_file_exist(file_path)
if File.exist?(file_path)
lines = []
CSV.foreach(file_path, headers: true, skip_blanks: true, converters: [:integer]) do |line|
lines << line.to_h.symbolize_keys
end
yield lines
else
puts "#{file_path} does not exist"
end
end
namespace :bec_import do
desc 'Prune unused BECs'
task :prune, [:file_path] => :environment do |_, args|
if_file_exist(args[:file_path]) do |lines|
bec_import = BecImport.new(lines)
bec_import.delete_unused
end
end
desc 'Update existing BECs'
task :update, [:file_path] => :environment do |_, args|
if_file_exist(args[:file_path]) do |lines|
bec_import = BecImport.new(lines)
bec_import.update_existing
end
end
end
| |
Add discussions for merge requests to notes controller | class NotesController < ProjectResourceController
# Authorize
before_filter :authorize_read_note!
before_filter :authorize_write_note!, only: [:create]
respond_to :js
def index
notes
if params[:target_type] == "merge_request"
@mixed_targets = true
@main_target_type = params[:target_type].camelize
end
respond_with(@notes)
end
def create
@note = Notes::CreateContext.new(project, current_user, params).execute
respond_to do |format|
format.html {redirect_to :back}
format.js
end
end
def destroy
@note = @project.notes.find(params[:id])
return access_denied! unless can?(current_user, :admin_note, @note)
@note.destroy
respond_to do |format|
format.js { render nothing: true }
end
end
def preview
render text: view_context.markdown(params[:note])
end
protected
def notes
@notes = Notes::LoadContext.new(project, current_user, params).execute
end
end
| class NotesController < ProjectResourceController
# Authorize
before_filter :authorize_read_note!
before_filter :authorize_write_note!, only: [:create]
respond_to :js
def index
@notes = Notes::LoadContext.new(project, current_user, params).execute
if params[:target_type] == "merge_request"
@mixed_targets = true
@main_target_type = params[:target_type].camelize
@discussions = discussions_from_notes
@has_diff = true
elsif params[:target_type] == "commit"
@has_diff = true
end
respond_with(@notes)
end
def create
@note = Notes::CreateContext.new(project, current_user, params).execute
respond_to do |format|
format.html {redirect_to :back}
format.js
end
end
def destroy
@note = @project.notes.find(params[:id])
return access_denied! unless can?(current_user, :admin_note, @note)
@note.destroy
respond_to do |format|
format.js { render nothing: true }
end
end
def preview
render text: view_context.markdown(params[:note])
end
protected
def discussion_notes_for(note)
@notes.select do |other_note|
note.discussion_id == other_note.discussion_id
end
end
def discussions_from_notes
discussion_ids = []
discussions = []
@notes.each do |note|
next if discussion_ids.include?(note.discussion_id)
# don't group notes for the main target
if for_main_target?(note)
discussions << [note]
else
discussions << discussion_notes_for(note)
discussion_ids << note.discussion_id
end
end
discussions
end
# Helps to distinguish e.g. commit notes in mr notes list
def for_main_target?(note)
!@mixed_targets || (@main_target_type == note.noteable_type && !note.for_diff_line?)
end
end
|
Remove filesystem dependency for parser spec | require 'spec_helper'
describe Codependency::Parser do
let( :path ){ File.join( File.dirname( __FILE__ ), '../fixtures' ) }
let( :parser ){ Codependency::Parser.new }
context 'body' do
subject { parser.parse( "#{path}/body.rb" ) }
it { should eq( [ ] ) }
end
context 'earth' do
subject { parser.parse( "#{path}/earth.rb" ) }
it { should eq( [ 'planet' ] ) }
end
context 'mars' do
subject { parser.parse( "#{path}/mars.rb" ) }
it { should eq( [ 'planet' ] ) }
end
context 'phobos' do
subject { parser.parse( "#{path}/phobos.rb" ) }
it { should eq( [ 'body', 'mars' ] ) }
end
context 'planet' do
subject { parser.parse( "#{path}/planet.rb" ) }
it { should eq( [ 'body' ] ) }
end
end
| require 'spec_helper'
describe Codependency::Parser do
let( :parser ){ Codependency::Parser.new }
before do
IO.stub( :readlines ) do |arg|
case File.basename( arg, '.rb' ).to_sym
when :body
"""
class Body
end
"""
when :earth
"""
# require planet
class Earth
end
"""
when :mars
"""
# require planet
class Mars
end
"""
when :phobos
"""
# require body
# require mars
class Phobos
end
"""
when :planet
"""
# require body
class Planet
end
"""
end.strip.split( /^\s+/ )
end
end
context 'body' do
subject { parser.parse( "body.rb" ) }
it { should eq( [ ] ) }
end
context 'earth' do
subject { parser.parse( "earth.rb" ) }
it { should eq( [ 'planet' ] ) }
end
context 'mars' do
subject { parser.parse( "mars.rb" ) }
it { should eq( [ 'planet' ] ) }
end
context 'phobos' do
subject { parser.parse( "phobos.rb" ) }
it { should eq( [ 'body', 'mars' ] ) }
end
context 'planet' do
subject { parser.parse( "planet.rb" ) }
it { should eq( [ 'body' ] ) }
end
end
|
Remove pipeline factory that is not used in tests | FactoryGirl.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do
ref 'master'
sha '97de212e80737a608d939f648d959671fb0a0142'
status 'pending'
project factory: :empty_project
factory :ci_pipeline_without_jobs do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { YAML.dump({}) }
end
end
factory :ci_pipeline_with_one_job do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { YAML.dump({ rspec: { script: "ls" } }) }
end
end
factory :ci_pipeline_with_two_job do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { YAML.dump({ rspec: { script: "ls" }, spinach: { script: "ls" } }) }
end
end
factory :ci_pipeline do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
end
end
factory(:ci_pipeline_with_yaml) do
transient { yaml nil }
after(:build) do |pipeline, evaluator|
raise ArgumentError unless evaluator.yaml
allow(pipeline).to receive(:ci_yaml_file)
.and_return(YAML.dump(evaluator.yaml))
end
end
end
end
| FactoryGirl.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do
ref 'master'
sha '97de212e80737a608d939f648d959671fb0a0142'
status 'pending'
project factory: :empty_project
factory :ci_pipeline_without_jobs do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { YAML.dump({}) }
end
end
factory :ci_pipeline_with_one_job do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { YAML.dump({ rspec: { script: "ls" } }) }
end
end
factory :ci_pipeline do
after(:build) do |commit|
allow(commit).to receive(:ci_yaml_file) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
end
end
factory(:ci_pipeline_with_yaml) do
transient { yaml nil }
after(:build) do |pipeline, evaluator|
raise ArgumentError unless evaluator.yaml
allow(pipeline).to receive(:ci_yaml_file)
.and_return(YAML.dump(evaluator.yaml))
end
end
end
end
|
Add gemspec summary and description | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bitsy_client/version'
Gem::Specification.new do |spec|
spec.name = "bitsy_client"
spec.version = BitsyClient::VERSION
spec.authors = ["Ramon Tayag"]
spec.email = ["ramon.tayag@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 'bitsy_client/version'
Gem::Specification.new do |spec|
spec.name = "bitsy_client"
spec.version = BitsyClient::VERSION
spec.authors = ["Ramon Tayag"]
spec.email = ["ramon.tayag@gmail.com"]
spec.description = %q{Bitsy Client gem used to create and query payment depots}
spec.summary = %q{Interface with the Bitsy Bitcoin payment server}
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
|
Add welcome_message to delegate to UserMailer and override confirm! method | class User < ActiveRecord::Base
has_many :startups
include Gravatar
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessor :login
validates_presence_of :username, :full_name
validates_uniqueness_of :username
validates_length_of :bio, :maximum => 120
def full_name
[first_name, last_name].join(' ') if first_name && last_name
end
def full_name=(name='')
split = name.split(' ', 2)
self.first_name = split.first
self.last_name = split.last
end
def self.roles
%w(developer designer hacker entrepreneur artist business).map do |role|
[role.titlecase, role]
end
end
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
else
where(conditions).first
end
end
end
| class User < ActiveRecord::Base
has_many :startups
include Gravatar
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
attr_accessor :login
validates_presence_of :username, :full_name
validates_uniqueness_of :username
validates_length_of :bio, :maximum => 120
def full_name
[first_name, last_name].join(' ') if first_name && last_name
end
def full_name=(name='')
split = name.split(' ', 2)
self.first_name = split.first
self.last_name = split.last
end
def self.roles
%w(developer designer hacker entrepreneur artist business).map do |role|
[role.titlecase, role]
end
end
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
else
where(conditions).first
end
end
def confirm!
welcome_message
super
end
private
def welcome_message
UserMailer.welcome_email(self).deliver
end
end
|
Include *.md files in the gem package | Gem::Specification.new do |spec|
spec.name = "rack-timeout"
spec.summary = "Abort requests that are taking too long"
spec.description = "Rack middleware which aborts requests that have been running for longer than a specified timeout."
spec.version = "0.5.1"
spec.homepage = "http://github.com/heroku/rack-timeout"
spec.author = "Caio Chassot"
spec.email = "caio@heroku.com"
spec.files = Dir[*%w( MIT-LICENSE CHANGELOG README.markdown lib/**/* doc/**/* )]
spec.license = "MIT"
spec.test_files = Dir.glob("test/**/*").concat([
"Gemfile",
"Rakefile"
])
spec.add_development_dependency("rake")
spec.add_development_dependency("rack-test")
spec.add_development_dependency("test-unit")
end
| Gem::Specification.new do |spec|
spec.name = "rack-timeout"
spec.summary = "Abort requests that are taking too long"
spec.description = "Rack middleware which aborts requests that have been running for longer than a specified timeout."
spec.version = "0.5.1"
spec.homepage = "http://github.com/heroku/rack-timeout"
spec.author = "Caio Chassot"
spec.email = "caio@heroku.com"
spec.files = Dir[*%w( MIT-LICENSE CHANGELOG.md UPGRADING.md README.md lib/**/* doc/**/* )]
spec.license = "MIT"
spec.test_files = Dir.glob("test/**/*").concat([
"Gemfile",
"Rakefile"
])
spec.add_development_dependency("rake")
spec.add_development_dependency("rack-test")
spec.add_development_dependency("test-unit")
end
|
Include rake task in gemspec files. | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'orientdb_schema_migrator/version'
require 'rake'
Gem::Specification.new do |spec|
spec.name = "orientdb-schema-migrator"
spec.version = OrientdbSchemaMigrator::VERSION
spec.authors = ["CoPromote"]
spec.email = ["info@copromote.com"]
spec.summary = %q{Migrate OrientDB schema}
spec.description = %q{Migrate OrientDB schema}
spec.homepage = "https://copromote.com"
spec.license = "MIT"
spec.files = FileList['lib/**/*.rb', '[A-Z]*'].exclude('Gemfile*')
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_dependency "orientdb4r", "~> 0.5"
spec.add_dependency "activesupport", ">= 3.0"
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "pry"
spec.add_development_dependency "rspec"
spec.add_development_dependency "climate_control", ">= 0.0.3"
end
| # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'orientdb_schema_migrator/version'
require 'rake'
Gem::Specification.new do |spec|
spec.name = "orientdb-schema-migrator"
spec.version = OrientdbSchemaMigrator::VERSION
spec.authors = ["CoPromote"]
spec.email = ["info@copromote.com"]
spec.summary = %q{Migrate OrientDB schema}
spec.description = %q{Migrate OrientDB schema}
spec.homepage = "https://copromote.com"
spec.license = "MIT"
spec.files = FileList['lib/**/*.{rb,rake}', '[A-Z]*'].exclude('Gemfile*')
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_dependency "orientdb4r", "~> 0.5"
spec.add_dependency "activesupport", ">= 3.0"
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "pry"
spec.add_development_dependency "rspec"
spec.add_development_dependency "climate_control", ">= 0.0.3"
end
|
Add implementation of NUID inboxes | module NATS
class NUID
DIGITS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
BASE = 62
PREFIX_LENGTH = 12
SEQ_LENGTH = 10
TOTAL_LENGTH = PREFIX_LENGTH + SEQ_LENGTH
MAX_SEQ = BASE**10
MIN_INC = 33
MAX_INC = 333
INC = MAX_INC - MIN_INC
def initialize
@prand = Random.new
@seq = @prand.rand(MAX_SEQ)
@inc = MIN_INC + @prand.rand(INC)
@prefix = ''
randomize_prefix!
end
def next
@seq += @inc
if @seq >= MAX_SEQ
randomize_prefix!
reset_sequential!
end
l = @seq
suffix = SEQ_LENGTH.times.reduce('') do |b|
b.prepend DIGITS[l % BASE]
l /= BASE
b
end
"#{@prefix}#{suffix}"
end
def randomize_prefix!
@prefix = \
SecureRandom.random_bytes(PREFIX_LENGTH).each_byte
.reduce('') do |prefix, n|
prefix << DIGITS[n % BASE]
end
end
private
def reset_sequential!
@seq = prand.rand(MAX_SEQ)
@inc = MIN_INC + @prand.rand(INC)
end
class << self
def next
@nuid ||= NUID.new.extend(MonitorMixin)
@nuid.synchronize do
@nuid.next
end
end
end
end
end
| |
Change maintainer info to HubSpot | name 'baragon'
maintainer 'EverTrue, Inc.'
maintainer_email 'eric.herot@evertrue.com'
license 'Apache 2.0'
description 'Installs/Configures baragon'
long_description 'Installs/Configures baragon'
version '1.0.0'
depends 's3_file'
depends 'java'
depends 'git'
| name 'baragon'
maintainer 'Tom Petr'
maintainer_email 'tpetr@hubspot.com'
license 'Apache 2.0'
description 'Installs/Configures baragon'
long_description 'Installs/Configures baragon'
version '1.0.0'
depends 's3_file'
depends 'java'
depends 'git'
|
Set up directory for checkout with proper perms | action :install do
if new_resource.create_user
group new_resource.group do
action :create
end
user new_resource.owner do
action :create
gid new_resource.group
end
end
# Update the code.
git new_resource.path do
action :sync
repository new_resource.repository
checkout_branch new_resource.revision
destination new_resource.path
user new_resource.owner
group new_resource.group
end
# If a config file template has been specified, create it.
template new_resource.config_template do
only_if { !new_resource.config_template.nil }
action :create
source new_resource.config_template
path new_resource.config_destination
variables new_resource.config_vars
owner new_resource.owner
group new_resource.group
end
# Install the application requirements.
# If a requirements file has been specified, use pip.
# otherwise use the setup.py
if new_resource.requirements_file
execute 'pip install' do
action :run
cwd new_resource.path
command "pip install -r #{new_resource.requirements_file}"
end
else
execute 'python setup.py install' do
action :run
cwd new_resource.path
end
end
new_resource.updated_by_last_action(true)
end
| action :install do
if new_resource.create_user
group new_resource.group do
action :create
end
user new_resource.owner do
action :create
gid new_resource.group
end
end
directory new_resource.path do
action :create
owner new_resource.owner
group new_resource.group
end
# Update the code.
git new_resource.path do
action :sync
repository new_resource.repository
checkout_branch new_resource.revision
destination new_resource.path
user new_resource.owner
group new_resource.group
end
# If a config file template has been specified, create it.
template new_resource.config_template do
only_if { !new_resource.config_template.nil }
action :create
source new_resource.config_template
path new_resource.config_destination
variables new_resource.config_vars
owner new_resource.owner
group new_resource.group
end
# Install the application requirements.
# If a requirements file has been specified, use pip.
# otherwise use the setup.py
if new_resource.requirements_file
execute 'pip install' do
action :run
cwd new_resource.path
command "pip install -r #{new_resource.requirements_file}"
end
else
execute 'python setup.py install' do
action :run
cwd new_resource.path
end
end
new_resource.updated_by_last_action(true)
end
|
Add method to game object class to return object pool. | module Asteroids
class GameObject
def initialize(object_pool)
@components = []
@object_pool = object_pool
@object_pool.objects << self
end
def components
@components
end
def update
@components.map(&:update)
end
def draw
@components.map(&:draw)
end
def removable?
@removable
end
def mark_for_removal
@removable = true
end
end
end | module Asteroids
class GameObject
def initialize(object_pool)
@components = []
@object_pool = object_pool
@object_pool.objects << self
end
def components
@components
end
def update
@components.map(&:update)
end
def draw
@components.map(&:draw)
end
def removable?
@removable
end
def mark_for_removal
@removable = true
end
protected
def object_pool
@object_pool
end
end
end |
Add Sass.load_paths entry to help absolute @import paths | module Bootstrap
class FrameworkNotFound < StandardError; end
# Inspired by Kaminari
def self.load!
if compass? && asset_pipeline?
register_compass_extension
register_rails_engine
elsif compass?
# Only require compass extension if a standalone project
require 'bootstrap-sass/compass_functions'
register_compass_extension
elsif asset_pipeline?
require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
register_rails_engine
require 'bootstrap-sass/rails_functions'
else
raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded"
end
end
private
def self.asset_pipeline?
defined?(::Rails) && ::Rails.version >= '3.1.0'
end
def self.compass?
defined?(::Compass)
end
def self.register_compass_extension
base = File.join(File.dirname(__FILE__), '..')
styles = File.join(base, 'vendor', 'assets', 'stylesheets')
templates = File.join(base, 'templates')
::Compass::Frameworks.register('bootstrap', :stylesheets_directory => styles, :templates_directory => templates)
end
def self.register_rails_engine
require 'bootstrap-sass/engine'
end
end
Bootstrap.load!
| module Bootstrap
class FrameworkNotFound < StandardError; end
# Inspired by Kaminari
def self.load!
if compass? && asset_pipeline?
register_compass_extension
register_rails_engine
elsif compass?
# Only require compass extension if a standalone project
require 'bootstrap-sass/compass_functions'
register_compass_extension
elsif asset_pipeline?
require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
register_rails_engine
require 'bootstrap-sass/rails_functions'
else
raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded"
end
stylesheets = File.expand_path(File.join("..", 'vendor', 'assets', 'stylesheets'))
Sass.load_paths << stylesheets
end
private
def self.asset_pipeline?
defined?(::Rails) && ::Rails.version >= '3.1.0'
end
def self.compass?
defined?(::Compass)
end
def self.register_compass_extension
base = File.join(File.dirname(__FILE__), '..')
styles = File.join(base, 'vendor', 'assets', 'stylesheets')
templates = File.join(base, 'templates')
::Compass::Frameworks.register('bootstrap', :stylesheets_directory => styles, :templates_directory => templates)
end
def self.register_rails_engine
require 'bootstrap-sass/engine'
end
end
Bootstrap.load!
|
Add extra params to extension type | Puppet::Type.newtype(:php_extension) do
@doc = "Install a PHP extension within a version of PHP"
ensurable do
newvalue :present do
provider.create
end
newvalue :absent do
provider.destroy
end
defaultto :present
end
newparam(:name) do
isnamevar
end
newparam(:version) do
defaultto '>= 0'
end
end
| Puppet::Type.newtype(:php_extension) do
@doc = "Install a PHP extension within a version of PHP"
ensurable do
newvalue :present do
provider.create
end
newvalue :absent do
provider.destroy
end
defaultto :present
end
newparam(:name) do
isnamevar
end
newparam(:extension) do
end
newparam(:version) do
defaultto '>= 0'
end
newparam(:package_name) do
end
newparam(:package_url) do
end
newparam(:phpenv_root) do
end
newparam(:php_version) do
end
end
|
Fix the remaining cucumber tests | module Featurable
extend ActiveSupport::Concern
included do
has_many :feature_lists, as: :featurable, dependent: :destroy
end
def feature_list_for_locale(locale)
feature_lists.find_by(locale: locale) || feature_lists.build(locale: locale)
end
def load_or_create_feature_list(locale)
feature_lists.find_by(locale: locale) || feature_lists.create(locale: locale)
end
end
| module Featurable
extend ActiveSupport::Concern
included do
has_many :feature_lists, as: :featurable, dependent: :destroy
end
def feature_list_for_locale(locale)
feature_lists.find_by(locale: locale) || feature_lists.build(locale: locale)
end
def load_or_create_feature_list(locale = nil)
locale = I18n.default_locale if locale.blank?
feature_lists.find_by(locale: locale) || feature_lists.create!(locale: locale)
end
end
|
Return false when validation fails | module StackMaster
class Validator
include Command
def initialize(stack_definition)
@stack_definition = stack_definition
end
def perform
StackMaster.stdout.print "#{@stack_definition.stack_name}: "
template_body = TemplateCompiler.compile(@stack_definition.template_file_path)
cf.validate_template(template_body: template_body)
StackMaster.stdout.puts "valid"
rescue Aws::CloudFormation::Errors::ValidationError => e
StackMaster.stdout.puts "invalid"
$stderr.puts e.message
end
private
def cf
@cf ||= StackMaster.cloud_formation_driver
end
end
end
| module StackMaster
class Validator
include Command
def initialize(stack_definition)
@stack_definition = stack_definition
end
def perform
StackMaster.stdout.print "#{@stack_definition.stack_name}: "
template_body = TemplateCompiler.compile(@stack_definition.template_file_path)
cf.validate_template(template_body: template_body)
StackMaster.stdout.puts "valid"
true
rescue Aws::CloudFormation::Errors::ValidationError => e
StackMaster.stdout.puts "invalid. #{e.message}"
false
end
private
def cf
@cf ||= StackMaster.cloud_formation_driver
end
end
end
|
Make testcase just a bit more failproof | #!/usr/bin/ruby
require 'test/unit'
require 'topaz'
require 'stone'
require 'rake'
include FileUtils
class TopazTestCase < Test::Unit::TestCase
def setup
@stone = Stone.existing('topaz_testing')
@stone.start
@topaz = Topaz.new(@stone)
end
def test_single_command
@topaz.commands(["status", "exit"])
fail "Output is #{@topaz.output[1]}" if /^Current settings are\:/ !~ @topaz.output[1]
end
def test_login
@topaz.commands(["set gems #{@stone.name} u DataCurator p swordfish", "login", "exit"])
fail "Output is #{@topaz.output[2]}" if /^successful login/ !~ @topaz.output[2]
end
end
| #!/usr/bin/ruby
require 'topaz'
require 'stone'
require 'test/unit'
require 'rake'
include FileUtils
TEST_STONE_NAME = 'testcase'
class TopazTestCase < Test::Unit::TestCase
def setup
if not GemStone.current.stones.include? TEST_STONE_NAME
@stone = Stone.create(TEST_STONE_NAME)
else
@stone = Stone.existing(TEST_STONE_NAME)
end
@stone.start
@topaz = Topaz.new(@stone)
end
def test_single_command
@topaz.commands(["status", "exit"])
fail "Output is #{@topaz.output[1]}" if /^Current settings are\:/ !~ @topaz.output[1]
end
def test_login
@topaz.commands(["set gems #{@stone.name} u DataCurator p swordfish", "login", "exit"])
fail "Output is #{@topaz.output[2]}" if /^successful login/ !~ @topaz.output[2]
end
end
|
Support including/extending the Utils module | module Subway
module Utils
def self.require_pattern(root, pattern)
Dir[root.join(pattern)].sort.each { |file| require file }
end
end # module Utils
end # module Subway
| module Subway
module Utils
extend self
def require_pattern(root, pattern)
Dir[root.join(pattern)].sort.each { |file| require file }
end
end # module Utils
end # module Subway
|
Use keyword arguments for boolean with default value | # frozen_string_literal: true
require 'singleton'
class Settings
attr_accessor :settings
include Singleton
class << self
def respond_to?(method, include_private = false)
super or instance.respond_to?(method, include_private)
end
protected
def method_missing(method, *args, &block)
return super unless instance.respond_to?(method)
instance.send(method, *args, &block)
end
end
def initialize
filename = File.join(File.dirname(__FILE__), *%W[.. settings #{Rails.env}.yml])
@settings = YAML.load(eval(ERB.new(File.read(filename)).src, nil, filename))
end
def respond_to?(method, include_private = false)
super or is_settings_query_method?(method) or @settings.key?(setting_key_for(method))
end
protected
def method_missing(method, *args, &block)
setting_key = setting_key_for(method)
setting_exists = @settings.key?(setting_key)
if is_settings_query_method?(method)
setting_exists
elsif setting_exists
@settings[setting_key]
else
super
end
end
private
def is_settings_query_method?(method)
method.to_s =~ /\?$/
end
def setting_key_for(method)
method.to_s.match(/^([^?]+)\??$/)[1]
end
end
Settings.instance
| # frozen_string_literal: true
require 'singleton'
class Settings
attr_accessor :settings
include Singleton
class << self
def respond_to?(method, include_private: false)
super or instance.respond_to?(method, include_private)
end
protected
def method_missing(method, *args, &block)
return super unless instance.respond_to?(method)
instance.send(method, *args, &block)
end
end
def initialize
filename = File.join(File.dirname(__FILE__), *%W[.. settings #{Rails.env}.yml])
@settings = YAML.load(eval(ERB.new(File.read(filename)).src, nil, filename))
end
def respond_to?(method, include_private: false)
super or is_settings_query_method?(method) or @settings.key?(setting_key_for(method))
end
protected
def method_missing(method, *args, &block)
setting_key = setting_key_for(method)
setting_exists = @settings.key?(setting_key)
if is_settings_query_method?(method)
setting_exists
elsif setting_exists
@settings[setting_key]
else
super
end
end
private
def is_settings_query_method?(method)
method.to_s =~ /\?$/
end
def setting_key_for(method)
method.to_s.match(/^([^?]+)\??$/)[1]
end
end
Settings.instance
|
Use modern version tag (without v) | Pod::Spec.new do |s|
s.name = 'AFNetworking-Synchronous'
s.version = '1.0.0'
s.summary = 'Synchronous requests for AFNetworking'
s.description = <<-DESC
A minimal category which extends AFNetworking to support synchronous
requests. Supports AFNetworking 1.x or 2.x.
DESC
s.homepage = 'https://github.com/paulmelnikow/AFNetworking-Synchronous'
s.license = 'MIT'
s.author = { "Paul Melnikow" => "github@paulmelnikow.com" }
s.source = { :git => 'https://github.com/paulmelnikow/AFNetworking-Synchronous.git',
:tag => "v#{s.version}" }
s.ios.deployment_target = '6.0'
s.requires_arc = true
s.subspec '1.x' do |sp|
s.osx.deployment_target = '10.7'
sp.source_files = '1.x'
sp.dependency 'AFNetworking', '~> 1.0'
end
s.subspec '2.x' do |sp|
s.osx.deployment_target = '10.8'
sp.source_files = '2.x'
sp.dependency 'AFNetworking', '~> 2.0'
end
s.default_subspec = '2.x'
end
| Pod::Spec.new do |s|
s.name = 'AFNetworking-Synchronous'
s.version = '1.0.0'
s.summary = 'Synchronous requests for AFNetworking'
s.description = <<-DESC
A minimal category which extends AFNetworking to support synchronous
requests. Supports AFNetworking 1.x or 2.x.
DESC
s.homepage = 'https://github.com/paulmelnikow/AFNetworking-Synchronous'
s.license = 'MIT'
s.author = { "Paul Melnikow" => "github@paulmelnikow.com" }
s.source = { :git => 'https://github.com/paulmelnikow/AFNetworking-Synchronous.git',
:tag => "#{s.version}" }
s.ios.deployment_target = '6.0'
s.requires_arc = true
s.subspec '1.x' do |sp|
s.osx.deployment_target = '10.7'
sp.source_files = '1.x'
sp.dependency 'AFNetworking', '~> 1.0'
end
s.subspec '2.x' do |sp|
s.osx.deployment_target = '10.8'
sp.source_files = '2.x'
sp.dependency 'AFNetworking', '~> 2.0'
end
s.default_subspec = '2.x'
end
|
Allow the ActiveSet instance methods (filter, sort, paginate) to be chainable | # frozen_string_literal: true
require 'active_set/version'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/hash/slice'
class ActiveSet
include Enumerable
def initialize(set)
@set = set
end
def each(&block)
@set.each(&block)
end
def filter(structure)
structure.reject { |_, value| value.blank? }
.reduce(@set) do |set, (key, value)|
set.select { |item| item.send(key) == value }
end
end
def sort(structure)
structure.reject { |_, value| value.blank? }
.reduce(@set) do |set, (key, value)|
set.sort_by { |item| item.send(key) }
.tap { |c| c.reverse! if value.to_s == 'desc' }
end
end
def paginate(structure)
pagesize = structure[:size] || 25
return @set if @set.count < pagesize
@set.each_slice(pagesize).take(structure[:page]).last
end
end
| # frozen_string_literal: true
require 'active_set/version'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/hash/slice'
class ActiveSet
include Enumerable
def initialize(set)
@set = set
end
def each(&block)
@set.each(&block)
end
def filter(structure)
self.class.new(structure.reject { |_, value| value.blank? }
.reduce(@set) do |set, (key, value)|
set.select { |item| item.send(key) == value }
end)
end
def sort(structure)
self.class.new(structure.reject { |_, value| value.blank? }
.reduce(@set) do |set, (key, value)|
set.sort_by { |item| item.send(key) }
.tap { |c| c.reverse! if value.to_s == 'desc' }
end)
end
def paginate(structure)
pagesize = structure[:size] || 25
return self.class.new(@set) if @set.count < pagesize
self.class.new(@set.each_slice(pagesize).take(structure[:page]).last)
end
end
|
Add missing license to gemspec, is MIT | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sucker_punch/version'
Gem::Specification.new do |gem|
gem.name = "sucker_punch"
gem.version = SuckerPunch::VERSION
gem.authors = ["Brandon Hilkert"]
gem.email = ["brandonhilkert@gmail.com"]
gem.description = %q{Asynchronous processing library for Ruby}
gem.summary = %q{Sucker Punch is a Ruby asynchronous processing using Celluloid, heavily influenced by Sidekiq and girl_friday.}
gem.homepage = "https://github.com/brandonhilkert/sucker_punch"
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_development_dependency "rspec"
gem.add_development_dependency "rake"
gem.add_development_dependency "pry"
gem.add_dependency "celluloid", "~> 0.15.2"
end
| # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sucker_punch/version'
Gem::Specification.new do |gem|
gem.name = "sucker_punch"
gem.version = SuckerPunch::VERSION
gem.authors = ["Brandon Hilkert"]
gem.email = ["brandonhilkert@gmail.com"]
gem.description = %q{Asynchronous processing library for Ruby}
gem.summary = %q{Sucker Punch is a Ruby asynchronous processing using Celluloid, heavily influenced by Sidekiq and girl_friday.}
gem.homepage = "https://github.com/brandonhilkert/sucker_punch"
gem.license = "MIT"
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_development_dependency "rspec"
gem.add_development_dependency "rake"
gem.add_development_dependency "pry"
gem.add_dependency "celluloid", "~> 0.15.2"
end
|
Clean up gemspec dependency versions. | $LOAD_PATH << './lib'
require 'cuprum/version'
Gem::Specification.new do |gem|
gem.name = 'cuprum'
gem.version = Cuprum::VERSION
gem.date = Time.now.utc.strftime '%Y-%m-%d'
gem.summary = 'A lightweight, functional-lite toolkit.'
description = <<-DESCRIPTION
A lightweight, functional-lite toolkit for making business logic a
first-class citizen of your application.
DESCRIPTION
gem.description = description.strip.gsub(/\n +/, ' ')
gem.authors = ['Rob "Merlin" Smith']
gem.email = ['merlin@sleepingkingstudios.com']
gem.homepage = 'http://sleepingkingstudios.com'
gem.license = 'MIT'
gem.require_path = 'lib'
gem.files = Dir['lib/**/*.rb', 'LICENSE', '*.md']
gem.add_development_dependency 'rspec', '~> 3.6'
gem.add_development_dependency 'rspec-sleeping_king_studios', '>= 2.3.0'
gem.add_development_dependency 'rubocop', '~> 0.49.1'
gem.add_development_dependency 'rubocop-rspec', '~> 1.15.1'
gem.add_development_dependency 'simplecov', '~> 0.15'
end # gemspec
| $LOAD_PATH << './lib'
require 'cuprum/version'
Gem::Specification.new do |gem|
gem.name = 'cuprum'
gem.version = Cuprum::VERSION
gem.date = Time.now.utc.strftime '%Y-%m-%d'
gem.summary = 'A lightweight, functional-lite toolkit.'
description = <<-DESCRIPTION
A lightweight, functional-lite toolkit for making business logic a
first-class citizen of your application.
DESCRIPTION
gem.description = description.strip.gsub(/\n +/, ' ')
gem.authors = ['Rob "Merlin" Smith']
gem.email = ['merlin@sleepingkingstudios.com']
gem.homepage = 'http://sleepingkingstudios.com'
gem.license = 'MIT'
gem.require_path = 'lib'
gem.files = Dir['lib/**/*.rb', 'LICENSE', '*.md']
gem.add_development_dependency 'rspec', '~> 3.6'
gem.add_development_dependency 'rspec-sleeping_king_studios', '~> 2.3'
gem.add_development_dependency 'rubocop', '~> 0.49.1'
gem.add_development_dependency 'rubocop-rspec', '~> 1.15'
gem.add_development_dependency 'simplecov', '~> 0.15'
end # gemspec
|
Add download method to import worker. | class DailyImportWorker
include Sidekiq::Worker
sidekiq_options queue: 'daily_import'
def perform
client = ClinicalTrials::Client.new
client.populate_studies
end
end
| class DailyImportWorker
include Sidekiq::Worker
sidekiq_options queue: 'daily_import'
def perform
client = ClinicalTrials::Client.new
client.download_xml_files
client.populate_studies
end
end
|
Rename uploaded images with a timestamp | # encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :small do
process :resize_to_fill => [300, 200]
end
version :hero do
process :resize_to_fill => [800, 300]
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# def filename
# "something.jpg" if original_filename
# end
end
| # encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :small do
process :resize_to_fill => [300, 200]
end
version :hero do
process :resize_to_fill => [800, 300]
end
def filename
Time.now.to_i.to_s + File.extname(@filename) if @filename
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# def filename
# "something.jpg" if original_filename
# end
end
|
Remove \n from author field in gemspec | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jquery/toastmessage/rails/version'
Gem::Specification.new do |spec|
spec.name = "jquery-toastmessage-rails"
spec.version = Jquery::Toastmessage::Rails::VERSION
spec.authors = ["Reyes Yang\n"]
spec.email = ["reyes.yang@gmail.com"]
spec.summary = %q{jQuery Toastmessage Plugin packaged for the Rails asset pipeline}
spec.description = %q{jQuery Toastmessage Plugin's JavaScript, Stylesheet and images packaged for Rails asset pipeline}
spec.homepage = "https://github.com/reyesyang/jquery-toastmessage-rails"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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_runtime_dependency 'rails', '>= 3.1.0'
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
end
| # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jquery/toastmessage/rails/version'
Gem::Specification.new do |spec|
spec.name = "jquery-toastmessage-rails"
spec.version = Jquery::Toastmessage::Rails::VERSION
spec.authors = ["Reyes Yang"]
spec.email = ["reyes.yang@gmail.com"]
spec.summary = %q{jQuery Toastmessage Plugin packaged for the Rails asset pipeline}
spec.description = %q{jQuery Toastmessage Plugin's JavaScript, Stylesheet and images packaged for Rails asset pipeline}
spec.homepage = "https://github.com/reyesyang/jquery-toastmessage-rails"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
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_runtime_dependency 'rails', '>= 3.1.0'
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
end
|
Validate the associations that can be performed | module Riews
class Relationship < ApplicationRecord
belongs_to :riews_view, class_name: 'Riews::View'
alias_method :view, :riews_view
validates_presence_of :view
validates :name, presence: true
end
end
| module Riews
class Relationship < ApplicationRecord
belongs_to :riews_view, class_name: 'Riews::View'
alias_method :view, :riews_view
validates_presence_of :view
validates :name, presence: true, inclusion: { in: proc{|r| r.view.klass.reflections.keys }}
end
end
|
Add some defaults to Configuration | class ServiceDesk::Configuration
OPTIONS = [:client_id, :client_secret, :redirect_uri, :api_host, :authenticate_path, :token_storage, :refresh_token]
OPTIONS.each do |option|
define_method(option) do |value=nil|
if value
instance_variable_set("@#{option}", value)
else
instance_variable_get("@#{option}")
end
end
end
end
| class ServiceDesk::Configuration
OPTIONS = [:client_id, :client_secret, :redirect_uri, :api_host, :authenticate_path, :token_storage, :refresh_token]
def initialize
api_host "https://deskapi.gotoassist.com"
authenticate_path "/v2/authenticate/oauth2"
end
OPTIONS.each do |option|
define_method(option) do |value=nil|
if value
instance_variable_set("@#{option}", value)
else
instance_variable_get("@#{option}")
end
end
end
end
|
Enable to subscribe events with private methods | require 'twterm/event_dispatcher'
module Twterm
module Subscriber
def subscribe(event, callback = nil, &block)
cb = if callback.is_a?(Proc)
callback
elsif callback.is_a?(Symbol)
if self.respond_to?(callback)
self.method(callback)
else
callback.to_proc
end
elsif callback.nil?
block
end
EventDispatcher.instance.register_subscription(object_id, event, cb)
end
def unsubscribe(event = nil)
EventDispatcher.instance.unregister_subscription(object_id, event)
end
def self.included(base)
base.instance_eval do
private :subscribe, :unsubscribe
end
end
end
end
| require 'twterm/event_dispatcher'
module Twterm
module Subscriber
def subscribe(event, callback = nil, &block)
cb = if callback.is_a?(Proc)
callback
elsif callback.is_a?(Symbol)
if self.respond_to?(callback, true)
self.method(callback)
else
callback.to_proc
end
elsif callback.nil?
block
end
EventDispatcher.instance.register_subscription(object_id, event, cb)
end
def unsubscribe(event = nil)
EventDispatcher.instance.unregister_subscription(object_id, event)
end
def self.included(base)
base.instance_eval do
private :subscribe, :unsubscribe
end
end
end
end
|
Fix coverall by moving Coveralls.wear on top | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'crazipsum'
require 'minitest/autorun'
require 'coveralls'
Coveralls.wear!
| $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'coveralls'
Coveralls.wear!
require 'crazipsum'
require 'minitest/autorun'
|
Upgrade acme-client gem to v0.6.2 | #
# Author:: Thijs Houtenbos <thoutenbos@schubergphilis.com>
# Cookbook:: acme
# Recipe:: default
#
# Copyright 2015-2017 Schuberg Philis
#
# 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.
#
chef_gem 'acme-client' do
action :install
version '0.4.0'
compile_time true if respond_to?(:compile_time)
end
require 'acme-client'
| #
# Author:: Thijs Houtenbos <thoutenbos@schubergphilis.com>
# Cookbook:: acme
# Recipe:: default
#
# Copyright 2015-2017 Schuberg Philis
#
# 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.
#
chef_gem 'acme-client' do
action :install
version '0.6.2'
compile_time true if respond_to?(:compile_time)
end
require 'acme-client'
|
Update gemspec for 0.3.2 release | Gem::Specification.new do |s|
s.name = "ruby-poker"
s.version = "0.3.1"
s.date = "2009-01-24"
s.rubyforge_project = "rubypoker"
s.platform = Gem::Platform::RUBY
s.summary = "Poker library in Ruby"
s.description = "Ruby library for comparing poker hands and determining the winner."
s.author = "Rob Olson"
s.email = "rko618@gmail.com"
s.homepage = "http://github.com/robolson/ruby-poker"
s.has_rdoc = true
s.files = ["CHANGELOG",
"examples/deck.rb",
"examples/quick_example.rb",
"lib/card.rb",
"lib/ruby-poker.rb",
"LICENSE",
"Rakefile",
"README.rdoc",
"ruby-poker.gemspec"]
s.test_files = ["test/test_card.rb",
"test/test_poker_hand.rb"]
s.require_paths << 'lib'
s.extra_rdoc_files = ["README", "CHANGELOG", "LICENSE"]
s.rdoc_options << '--title' << 'Ruby Poker Documentation' <<
'--main' << 'README.rdoc' <<
'--inline-source' << '-q'
# s.add_dependency("thoughtbot-shoulda", ["> 2.0.0"])
end
| spec = Gem::Specification.new do |s|
s.name = "ruby-poker"
s.version = RUBYPOKER_VERSION
s.date = "2009-07-27"
s.rubyforge_project = "rubypoker"
s.platform = Gem::Platform::RUBY
s.summary = "Poker library in Ruby"
s.description = "Ruby library for comparing poker hands and determining the winner."
s.author = "Rob Olson"
s.email = "rob@thinkingdigitally.com"
s.homepage = "http://github.com/robolson/ruby-poker"
s.has_rdoc = true
s.files = ["CHANGELOG",
"examples/deck.rb",
"examples/quick_example.rb",
"lib/ruby-poker.rb",
"lib/ruby-poker/card.rb",
"lib/ruby-poker/poker_hand.rb",
"LICENSE",
"Rakefile",
"README.rdoc",
"ruby-poker.gemspec"]
s.test_files = ["test/test_helper.rb", "test/test_card.rb", "test/test_poker_hand.rb"]
s.require_paths << 'lib'
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG", "LICENSE"]
s.rdoc_options << '--title' << 'Ruby Poker Documentation' <<
'--main' << 'README.rdoc' <<
'--inline-source' << '-q'
s.add_development_dependency('thoughtbot-shoulda', '> 2.0.0')
end
|
Exclude code block style from Markdownlint | all # Use all markdownlint rules
# Disable line length check for tables and code blocks
rule 'MD013', :line_length => 80, :code_blocks => false, :tables => false
# Set Ordered list item prefix to "ordered" (use 1. 2. 3. not 1. 1. 1.)
rule 'MD029', :style => "ordered"
| all # Use all markdownlint rules
# Disable line length check for tables and code blocks
rule 'MD013', :line_length => 80, :code_blocks => false, :tables => false
# Set Ordered list item prefix to "ordered" (use 1. 2. 3. not 1. 1. 1.)
rule 'MD029', :style => "ordered"
# Exclude code block style
exclude_rule 'MD046'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.