source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | Guardfile | Ruby | mit | 201 | master | 536 | #!/usr/bin/ruby
guard_opts = {
all_on_start: true,
all_after_pass: true,
}
def all
'spec'
end
group :bundler do
guard 'bundler' do
watch('Gemfile')
end
end
group :tests do
guard 'rspec', guard_opts do
watch(%r{^spec/spec_helper\.rb}) { all }
watch(%r{^spec/support/.+\.rb}) ... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | rvm-capistrano.gemspec | Ruby | mit | 201 | master | 1,018 | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'rvm/capistrano/version'
require 'yaml'
Gem::Specification.new do |spec|
spec.name = 'rvm-capistrano'
spec.version = ::RVM::Capistrano::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ['Wayn... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano.rb | Ruby | mit | 201 | master | 339 | # Recipes for using RVM on a server with capistrano.
require 'rvm/capistrano/selector'
require 'rvm/capistrano/info_list'
require 'rvm/capistrano/install_rvm'
require 'rvm/capistrano/install_ruby'
require 'rvm/capistrano/create_gemset'
# E.g, to use ree and rails 3:
#
# require 'rvm/capistrano'
# set :rvm_ruby_st... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/selector.rb | Ruby | mit | 201 | master | 439 | require 'rvm/capistrano/base'
rvm_with_capistrano do
deferred_load do
# conflicts with rvm/capistrano/selector_mixed
unless fetch(:rvm_require_role,nil).nil?
raise "
ERROR: found: 'set :rvm_require_role, \"#{fetch(:rvm_require_role,nil)}\"',
it conflicts with 'require \"rvm/capistrano/sele... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/info_list.rb | Ruby | mit | 201 | master | 381 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/with_rvm_group'
rvm_with_capistrano do
namespace :rvm do
desc "Show rvm info"
rvm_task :info do
run_rvm("info")
end
desc "List rvm rubies"
rvm_task :list do
run_rvm("list")
end
desc "Show info and list rubies"
... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/empty_gemset.rb | Ruby | mit | 201 | master | 597 | # Extension to empty gemset.
require 'rvm/capistrano/base'
rvm_with_capistrano do
namespace :rvm do
desc "Empty gemset"
task :empty_gemset do
ruby, gemset = rvm_ruby_string_evaluated.to_s.strip.split /@/
if %w( release_path default ).include? "#{ruby}"
raise "gemset can not be emptied w... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/install_ruby.rb | Ruby | mit | 201 | master | 2,218 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/run_silent_curl'
require 'rvm/capistrano/helpers/rvm_if_sudo'
require 'rvm/capistrano/helpers/with_rvm_group'
rvm_with_capistrano do
deferred_load do
# Let users set the (re)install for ruby.
_cset(:rvm_install_ruby, :install)
# Pass no spe... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/selector_mixed.rb | Ruby | mit | 201 | master | 882 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/quote_and_escape'
rvm_with_capistrano do
if fetch(:rvm_require_role,nil).nil?
raise "
ERROR: no 'set :rvm_require_role, \"...\"' declared before 'rvm/capistrano/selector_mixed',
it is required for proper functioning, please add it and try aga... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/base.rb | Ruby | mit | 201 | master | 3,696 | require 'rvm/capistrano/helpers/_cset'
require 'rvm/capistrano/helpers/rvm_methods'
rvm_with_capistrano do
deferred_load do
_cset :rvm_shell do
shell = File.join(rvm_bin_path, "rvm-shell")
ruby = fetch(:rvm_ruby_string_evaluated).strip
case ruby
when "release_path"
shell = "rvm_p... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/create_gemset.rb | Ruby | mit | 201 | master | 625 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/with_rvm_group'
rvm_with_capistrano do
namespace :rvm do
desc "Create gemset"
rvm_task :create_gemset do
ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
if %w( release_path default ).include? "#{ruby}"
r... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/alias_and_wrapp.rb | Ruby | mit | 201 | master | 692 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/with_rvm_group'
rvm_with_capistrano do
namespace :rvm do
desc "Create application alias"
rvm_task :create_alias do
run_rvm("alias create #{application} #{rvm_ruby_string_evaluated}", :with_rvm_group => true)
end
desc "Show applicat... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/gem_install_uninstall.rb | Ruby | mit | 201 | master | 590 | require 'rvm/capistrano/base'
rvm_with_capistrano do
namespace :rvm do
desc "Install a gem, 'cap rvm:install_gem GEM=my_gem'."
rvm_task :install_gem do
run_rvm("gem install #{ENV['GEM']}",
:with_ruby => rvm_ruby_string_evaluated,
:subject_class => :gemsets)
end
d... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/install_pkgs.rb | Ruby | mit | 201 | master | 956 | require 'rvm/capistrano/base'
rvm_with_capistrano do
warn "task 'rvm:install_pkgs' is deprecated, please read about autolibs => http://rvm.io/rvm/autolibs especially check the autolibs mode 'rvm_pkg'."
deferred_load do
# Additional rvm packages to install.
_cset(:rvm_install_pkgs, [])
end
namespac... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/install_rvm.rb | Ruby | mit | 201 | master | 1,216 | require 'rvm/capistrano/base'
require 'rvm/capistrano/helpers/run_silent_curl'
require 'rvm/capistrano/helpers/rvm_if_sudo'
rvm_with_capistrano do
deferred_load do
# Let users set the install type of their choice.
_cset(:rvm_install_type, :stable)
_cset(:rvm_install_url, "https://get.rvm.io")
# B... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/gemset_import_export.rb | Ruby | mit | 201 | master | 1,606 | require 'rvm/capistrano/base'
rvm_with_capistrano do
namespace :rvm do
desc <<-EOF
Import file contents to the current RVM ruby gemset.
The gemset filename must match :rvm_ruby_string.gems and be located in :rvm_gemset_path.
:rvm_gemset_path defaults to :rvm_path/gemsets
The gemset ca... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/_cset.rb | Ruby | mit | 201 | master | 273 | require 'rvm/capistrano/helpers/base'
rvm_with_capistrano do
unless methods.map(&:to_sym).include?(:_cset)
# Taken from the capistrano code.
def _cset(name, *args, &block)
unless exists?(name)
set(name, *args, &block)
end
end
end
end |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/rvm_methods.rb | Ruby | mit | 201 | master | 2,333 | module Capistrano
module RvmMethods
# defined depending on which selector was used
def rvm_task(name,&block)
if fetch(:rvm_require_role,nil).nil?
task name, &block
else
task name, :roles => fetch(:rvm_require_role), &block
end
end
# allow running tasks without using ... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/run_silent_curl.rb | Ruby | mit | 201 | master | 513 | require 'rvm/capistrano/base'
rvm_with_capistrano do
def run_silent_curl(command, options={})
run_without_rvm(<<-EOF.gsub(/[\s]+/, ' '))
__LAST_STATUS=0;
export CURL_HOME="${TMPDIR:-${HOME}}/.rvm-curl-config.$$";
mkdir ${CURL_HOME}/;
{
[[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curl... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/with_rvm_group.rb | Ruby | mit | 201 | master | 474 | require 'rvm/capistrano/helpers/base'
require 'rvm/capistrano/helpers/rvm_if_sudo'
require 'rvm/capistrano/helpers/quote_and_escape'
rvm_with_capistrano do
def with_rvm_group(command, options = {})
if need_root(options)
rvm_user_command + <<-CODE
if id | grep ' groups=.*(rvm)' >/dev/null ;
then #{command}... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/rvm_if_sudo.rb | Ruby | mit | 201 | master | 1,750 | require 'rvm/capistrano/base'
rvm_with_capistrano do
deferred_load do
# Default sudo state
_cset(:rvm_install_with_sudo, false)
end
def rvm_if_sudo(options = {})
return '' unless need_root(options)
prohibited = sudo_prohibited(options)
return prohibited if prohibited # will cause a deferred... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | lib/rvm/capistrano/helpers/base.rb | Ruby | mit | 201 | master | 412 | module Capistrano
class Configuration
def deferred_load(&block)
if current_task
instance_eval(&block)
else
on(:load, &block)
end
end
end
end
def rvm_with_capistrano(&block)
if Capistrano.const_defined?(:Configuration) &&
Capistrano::Configuration.methods.map(&:to_s... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/rvm_paths_spec.rb | Ruby | mit | 201 | master | 3,112 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "rvm paths" do
include_context "Capistrano::Configuration"
describe "default values" do
before { @configuration.trigger(:load) }
it "should return default system path" do
expect(@configuration.fetch(:rvm_system_path)).to eq(... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/empty_gemset_spec.rb | Ruby | mit | 201 | master | 1,194 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "rvm:create_gemset task" do
include_context "Capistrano::Configuration"
before {
@configuration.require 'rvm/capistrano/empty_gemset'
@gemset = 'mygemset'
@configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
@task = @con... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/create_gemset_spec.rb | Ruby | mit | 201 | master | 1,675 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "rvm:create_gemset task" do
include_context "Capistrano::Configuration"
before {
@gemset = 'mygemset'
@configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
@task = @configuration.find_task 'rvm:create_gemset'
}
it "shoul... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/install_ruby_spec.rb | Ruby | mit | 201 | master | 4,422 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "rvm:install_ruby task" do
include_context "Capistrano::Configuration"
before {
@gemset = 'mygemset'
@configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
@task = @configuration.find_task 'rvm:install_ruby'
}
it "should ... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/support/capistrano.rb | Ruby | mit | 201 | master | 698 | require 'capistrano-spec'
require 'capistrano'
RSpec.configure do |config|
config.include Capistrano::Spec::Matchers
config.include Capistrano::Spec::Helpers
end
shared_context "Capistrano::Configuration" do
before do
@configuration = Capistrano::Configuration.new
$:.unshift File.dirname(__FILE__) + '/.... |
github | rvm/rvm-capistrano | https://github.com/rvm/rvm-capistrano | spec/support/abort_matcher.rb | Ruby | mit | 201 | master | 887 | require 'rspec/expectations'
RSpec::Matchers.define :abort_with_error do |message|
match do |block|
@block = block
with_fake_stderr do
@got_system_exit = false
begin
block.call
rescue SystemExit
@got_system_exit = true
@stderr = $stderr.string
message ? messa... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | couch_foo.gemspec | Ruby | mit | 201 | master | 3,231 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{couch_foo}
s.version = "0.8.7"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | Rakefile | Ruby | mit | 201 | master | 1,584 | require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "couch_foo"
s.summary = %Q{CouchFoo provides an ActiveRecord API interface to CouchDB}
s.email = "george.palmer@gmail.com"
s.homepage = "http://github.com/georgepalmer/couch_foo"
s.description = "CouchFoo provides an Acti... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo.rb | Ruby | mit | 201 | master | 1,311 | require 'rubygems'
require 'active_support'
require 'json'
require 'json/add/core'
require 'json/add/rails'
require 'uuid'
require 'ostruct'
require 'boolean'
require 'couch_foo/base'
require 'couch_foo/database'
require 'couch_foo/database_version'
require 'couch_foo/view_methods'
require 'couch_foo/named_scope'
requ... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/view_methods.rb | Ruby | mit | 201 | master | 9,769 | # The view code uses some of the code developed by Alexander Lang (http://upstream-berlin.com/) in
# CouchPotato.
module CouchFoo
module ViewMethods
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
# Method that does find_by_id, find_by_username_and_type vie... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/observer.rb | Ruby | mit | 201 | master | 7,024 | require 'singleton'
require 'set'
module CouchFoo
module Observing # :nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
# Activates the observers assigned. Examples:
#
# # Calls PersonObserver.instance
# CouchFoo::Base.observers = :person_o... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/database_version.rb | Ruby | mit | 201 | master | 1,041 | module CouchFoo
# this class was taken from the issues list on Couch Foo
# see: http://github.com/zedalaye
# http://github.com/georgepalmer/couch_foo/issues#issue/1
class DatabaseVersion
attr_accessor :major, :minor, :patch
def initialize(version)
self.major = 0
self.minor = 0
self.patch ... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/serialization.rb | Ruby | mit | 201 | master | 3,642 | module CouchFoo #:nodoc:
module Serialization
class Serializer #:nodoc:
attr_reader :options
def initialize(record, options = {})
@record, @options = record, options.dup
end
# To replicate the behavior in CouchFoo#attributes,
# <tt>:except</tt> takes precedence over <tt>:on... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/callbacks.rb | Ruby | mit | 201 | master | 12,393 | require 'observer'
module CouchFoo
# Callbacks are hooks into the lifecycle of a Couch Foo object that allow you to trigger logic
# before or after an alteration of the object state. This can be used to make sure that associated
# and dependent objects are deleted when destroy is called (by overwriting +before_... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations.rb | Ruby | mit | 201 | master | 59,679 | require 'couch_foo/associations/association_proxy'
require 'couch_foo/associations/association_collection'
require 'couch_foo/associations/belongs_to_association'
require 'couch_foo/associations/belongs_to_polymorphic_association'
require 'couch_foo/associations/has_one_association'
require 'couch_foo/associations/has_... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/named_scope.rb | Ruby | mit | 201 | master | 6,447 | module CouchFoo
module NamedScope
# All subclasses of CouchFoo::Base have two named_scopes:
# * <tt>all</tt>, which is similar to a <tt>find(:all)</tt> query, and
# * <tt>scoped</tt>, which allows for the creation of anonymous scopes, on the fly: <tt>Shirt.scoped(:conditions => {:color => 'red'}).scoped(:... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/database.rb | Ruby | mit | 201 | master | 5,950 | require 'couchrest'
# This class wrappers CouchRest but may ultimately replace it as only parts of the library are used
module CouchFoo
class DatabaseWrapper
attr_accessor :database, :database_version, :bulk_save_default
def initialize(options, bulk_save_default, *args)
self.database = Couch... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/validations.rb | Ruby | mit | 201 | master | 47,805 | module CouchFoo
# Raised by save! and create! when the record is invalid. Use the
# +record+ method to retrieve the record which did not validate.
# begin
# complex_operation_that_calls_save!_internally
# rescue CouchFoo::RecordInvalid => invalid
# puts invalid.record.errors
# end
class R... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/attribute_methods.rb | Ruby | mit | 201 | master | 12,564 | module CouchFoo
module AttributeMethods
DEFAULT_SUFFIXES = %w(= ? _before_type_cast)
ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [Time, DateTime, Date]
JSON_DATETIME_FORMAT = "%Y/%m/%d %H:%M:%S +0000"
def self.included(base)
base.extend ClassMethods
base.attribute_method_suffix(*DEFAULT_SUFFI... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/reflection.rb | Ruby | mit | 201 | master | 9,819 | module CouchFoo
module Reflection # :nodoc:
def self.included(base)
base.extend(ClassMethods)
end
# Reflection allows you to interrogate Couch Foo classes and objects about their associations and aggregations.
# This information can, for example, be used in a form builder that took an Couch Foo... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/timestamp.rb | Ruby | mit | 201 | master | 1,639 | module CouchFoo
# Couch Foo automatically timestamps create and update operations if the document has attributes
# named created_at/created_on or updated_at/updated_on.
#
# Timestamping can be turned off by setting
# <tt>ActiveRecord::Base.record_timestamps = false</tt>
#
# Timestamps are in the local t... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/base.rb | Ruby | mit | 201 | master | 99,911 | require 'digest/md5'
require 'couchrest'
module CouchFoo
# Generic Active Record exception class.
class CouchFooError < StandardError
end
# Raised when the inheritance mechanism failes to locate the subclass
# (for example due to improper usage of column that +inheritance_column+ points to).
class Su... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/dirty.rb | Ruby | mit | 201 | master | 4,389 | module CouchFoo
# Track unsaved attribute changes.
#
# A newly instantiated object is unchanged:
# person = Person.find_by_name('uncle bob')
# person.changed? # => false
#
# Change the name:
# person.name = 'Bob'
# person.changed? # => true
# person.name_changed? # => true
#... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/calculations.rb | Ruby | mit | 201 | master | 5,156 | module CouchFoo
module Calculations #:nodoc:
CALCULATIONS_OPTIONS = [:conditions, :order, :distinct, :limit, :count, :offset, :include]
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Count operates using two different approaches.
#
# * Count all: B... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/belongs_to_polymorphic_association.rb | Ruby | mit | 201 | master | 1,385 | module CouchFoo
module Associations
class BelongsToPolymorphicAssociation < AssociationProxy #:nodoc:
def replace(record)
if record.nil?
@target = @owner[@reflection.primary_key_name] = @owner[@reflection.options[:foreign_type]] = nil
else
@target = (AssociationProxy === ... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/has_and_belongs_to_many_association.rb | Ruby | mit | 201 | master | 4,685 | #TODO column, sql, record and table search
module CouchFoo
module Associations
class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc:
def create(attributes = {})
create_record(attributes) { |record| insert_record(record, true) }
end
def create!(attributes = {})
cr... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/belongs_to_association.rb | Ruby | mit | 201 | master | 1,750 | module CouchFoo
module Associations
class BelongsToAssociation < AssociationProxy #:nodoc:
def create(attributes = {})
replace(@reflection.klass.create(attributes))
end
def build(attributes = {})
replace(@reflection.klass.new(attributes))
end
def replace(record)
... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/association_collection.rb | Ruby | mit | 201 | master | 10,654 | require 'set'
module CouchFoo
module Associations
class AssociationCollection < AssociationProxy #:nodoc:
def initialize(owner, reflection)
super
construct_conditions
end
def find(*args)
options = args.extract_options!
options[:conditions] = @asso... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/has_many_association.rb | Ruby | mit | 201 | master | 3,524 | module CouchFoo
module Associations
class HasManyAssociation < AssociationCollection #:nodoc:
# Count the number of associated records.
# With CouchDB it does not make sense to have a second view for this count as it is likely
# that at some point the developer will access the objects themselves... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/has_one_association.rb | Ruby | mit | 201 | master | 3,082 | module CouchFoo
module Associations
class HasOneAssociation < BelongsToAssociation #:nodoc:
def initialize(owner, reflection)
super
construct_conditions
end
def create(attrs = {}, replace_existing = true)
new_record(replace_existing) { |klass| klass.create(attrs) }
... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/associations/association_proxy.rb | Ruby | mit | 201 | master | 6,364 | module CouchFoo
module Associations
# This is the root class of all association proxies:
#
# AssociationProxy
# BelongsToAssociation
# HasOneAssociation
# BelongsToPolymorphicAssociation
# AssociationCollection
# HasAndBelongsToManyAssociation
# HasM... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/serializers/json_serializer.rb | Ruby | mit | 201 | master | 2,992 | module CouchFoo #:nodoc:
module Serialization
def self.included(base)
base.cattr_accessor :include_root_in_json, :instance_writer => false
base.extend ClassMethods
end
# Returns a JSON string representing the model. Some configuration is
# available through +options+.
#
# Without ... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | lib/couch_foo/serializers/xml_serializer.rb | Ruby | mit | 201 | master | 11,249 | module CouchFoo #:nodoc:
module Serialization
# Builds an XML document to represent the model. Some configuration is
# available through +options+. However more complicated cases should
# override CouchFoo::Base#to_xml. This is a necessary step if you wish
# to use custom types
#
# By default... |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | features/support/env.rb | Ruby | mit | 201 | master | 217 | $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
require 'couch_foo'
require 'test/unit/assertions'
require 'test/unit/assertions'
World do |world|
world.extend(Test::Unit::Assertions)
world
end |
github | georgepalmer/couch_foo | https://github.com/georgepalmer/couch_foo | test/couch_foo_test.rb | Ruby | mit | 201 | master | 254 | require File.dirname(__FILE__) + '/test_helper'
class CouchFooTest < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
end |
github | iain/roundsman | https://github.com/iain/roundsman | Rakefile | Ruby | mit | 201 | master | 306 | #!/usr/bin/env rake
require "bundler/gem_tasks"
namespace :test do
desc "Run integration test for Ubuntu 10.04 LTE"
task :lucid do
result = system "cd test/ubuntu-lucid && ./test.sh"
exit 1 unless result
end
task :all => [ :lucid ]
end
task :test => "test:all"
task :default => :test |
github | iain/roundsman | https://github.com/iain/roundsman | roundsman.gemspec | Ruby | mit | 201 | master | 910 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/roundsman/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["iain"]
gem.email = ["iain@iain.nl"]
gem.description = %q{Combine the awesome powers of Capistrano and Chef. The only thing you need is SSH access.}
gem.summar... |
github | iain/roundsman | https://github.com/iain/roundsman | lib/roundsman/capistrano.rb | Ruby | mit | 201 | master | 9,975 | require 'json'
require 'tempfile'
::Capistrano::Configuration.instance(:must_exist).load do
namespace :roundsman do
def run_list(*recipes)
if recipes.any?
set :run_list, recipes
install_ruby if fetch(:run_roundsman_checks, true) && install_ruby?
run_chef
else
Array(f... |
github | iain/roundsman | https://github.com/iain/roundsman | test/ubuntu-lucid/Vagrantfile | Ruby | mit | 201 | master | 3,959 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment r... |
github | iain/roundsman | https://github.com/iain/roundsman | test/ubuntu-lucid/config/deploy.rb | Ruby | mit | 201 | master | 467 | set :application, "my-awesome-blog"
set :repository, "."
set :scm, :none # not recommended in production
set :deploy_via, :copy
server "192.168.33.10", :web, :app, :db, :primary => true
set :user, "vagrant"
set :password, "vagrant" # not recommended in production
set :deploy_to, "/home/#{user}/#{applicat... |
github | jekyll/jekyll-mentions | https://github.com/jekyll/jekyll-mentions | jekyll-mentions.gemspec | Ruby | mit | 201 | main | 789 | # frozen_string_literal: true
require_relative "lib/jekyll-mentions/version"
Gem::Specification.new do |s|
s.name = "jekyll-mentions"
s.summary = "@mention support for your Jekyll site"
s.version = JekyllMentions::VERSION
s.authors = ["GitHub, Inc."]
s.email = "support@github.com"
... |
github | jekyll/jekyll-mentions | https://github.com/jekyll/jekyll-mentions | lib/jekyll-mentions.rb | Ruby | mit | 201 | main | 4,250 | # frozen_string_literal: true
require "jekyll"
require "html/pipeline"
module Jekyll
class Mentions
GITHUB_DOT_COM = "https://github.com"
BODY_START_TAG = "<body"
OPENING_BODY_TAG_REGEX = %r!<body(.*?)>\s*!m.freeze
InvalidJekyllMentionConfig = Class.new(Jekyll::Errors::FatalException)
class <... |
github | jekyll/jekyll-mentions | https://github.com/jekyll/jekyll-mentions | spec/mentions_spec.rb | Ruby | mit | 201 | main | 8,103 | # frozen_string_literal: true
RSpec.describe(Jekyll::Mentions) do
Jekyll.logger.log_level = :error
let(:config_overrides) { {} }
let(:configs) do
Jekyll.configuration(
config_overrides.merge(
"skip_config_files" => false,
"collections" => { "docs" => { "output" => true } },
... |
github | jekyll/jekyll-mentions | https://github.com/jekyll/jekyll-mentions | spec/spec_helper.rb | Ruby | mit | 201 | main | 3,021 | # frozen_string_literal: true
require File.expand_path("../lib/jekyll-mentions.rb", __dir__)
FIXTURES_DIR = File.expand_path("fixtures", __dir__)
RSpec.configure do |config|
def fixtures_dir(*paths)
File.join(FIXTURES_DIR, *paths)
end
def find_by_title(docs, title)
docs.find { |d| d.data["title"] == t... |
github | tycooon/memery | https://github.com/tycooon/memery | memery.gemspec | Ruby | mit | 201 | master | 730 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "memery/version"
Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 3.2.0"
spec.name = "memery"
spec.version = Memery::VERSION
spec.authors ... |
github | tycooon/memery | https://github.com/tycooon/memery | benchmark.rb | Ruby | mit | 201 | master | 1,459 | # frozen_string_literal: true
require "bundler/setup"
Bundler.setup
require "benchmark"
require "benchmark/ips"
require "benchmark/memory"
puts "```ruby"
puts File.read(__FILE__)
puts "```"
puts
puts "### Output"
puts
puts "```"
require_relative "lib/memery"
class Foo
class << self
include Memery
def ba... |
github | tycooon/memery | https://github.com/tycooon/memery | Rakefile | Ruby | mit | 201 | master | 286 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubocop/rake_task"
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:lint)
task default: %i[lint spec]
desc "run benchmark"
task :benchmark do
require_relative "benchmark"
end |
github | tycooon/memery | https://github.com/tycooon/memery | Gemfile | Ruby | mit | 201 | master | 248 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "activesupport"
gem "benchmark-ips"
gem "benchmark-memory"
gem "bundler"
gem "pry"
gem "rake"
gem "rspec"
gem "rubocop-config-umbrellio"
gem "simplecov"
gem "simplecov-lcov" |
github | tycooon/memery | https://github.com/tycooon/memery | lib/memery.rb | Ruby | mit | 201 | master | 3,945 | # frozen_string_literal: true
require "memery/version"
module Memery
class << self
attr_accessor :use_hashed_arguments
def monotonic_clock
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
end
@use_hashed_arguments = true
OUR_BLOCK = lambda do
extend(ClassMethods)
include(Instan... |
github | tycooon/memery | https://github.com/tycooon/memery | spec/memery_spec.rb | Ruby | mit | 201 | master | 11,860 | # frozen_string_literal: true
# rubocop:disable Style/MutableConstant
CALLS = []
B_CALLS = []
# rubocop:enable Style/MutableConstant
class A
include Memery
attr_accessor :environment
memoize def m
m_private
end
memoize
def m_different_line
CALLS << :m_different_line
:m_different_line
end
... |
github | tycooon/memery | https://github.com/tycooon/memery | spec/spec_helper.rb | Ruby | mit | 201 | master | 840 | # frozen_string_literal: true
require "simplecov"
require "simplecov-lcov"
SimpleCov::Formatter::LcovFormatter.config do |config|
config.report_with_single_file = true
config.single_report_path = "coverage/lcov.info"
end
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTM... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | Rakefile | Ruby | mit | 201 | master | 396 | require 'rake'
require 'rake/clean'
require 'rake/testtask'
CLOBBER.include('pkg')
directory 'pkg'
desc 'Build distributable packages'
task :build => [:pkg] do
system 'gem build json-stream.gemspec && mv json-*.gem pkg/'
end
Rake::TestTask.new(:test) do |test|
test.libs << 'spec'
test.pattern = 'spec/**/*_spe... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | json-stream.gemspec | Ruby | mit | 201 | master | 797 | require './lib/json/stream/version'
Gem::Specification.new do |s|
s.name = 'json-stream'
s.version = JSON::Stream::VERSION
s.summary = %q[A streaming JSON parser that generates SAX-like events.]
s.description = %q[A parser best suited for huge JSON documents that don't fit in memory.]
s.autho... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | lib/json/stream/parser.rb | Ruby | mit | 201 | master | 16,917 | module JSON
module Stream
# Raised on any invalid JSON text.
ParserError = Class.new(RuntimeError)
# A streaming JSON parser that generates SAX-like events for state changes.
# Use the json gem for small documents. Use this for huge documents that
# won't fit in memory.
#
# Examples
#... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | lib/json/stream/buffer.rb | Ruby | mit | 201 | master | 2,967 | module JSON
module Stream
# A character buffer that expects a UTF-8 encoded stream of bytes.
# This handles truncated multi-byte characters properly so we can just
# feed it binary data and receive a properly formatted UTF-8 String as
# output.
#
# More UTF-8 parsing details are available at:
... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | lib/json/stream/builder.rb | Ruby | mit | 201 | master | 1,497 | module JSON
module Stream
# A parser listener that builds a full, in memory, object from a JSON
# document. This is similar to using the json gem's `JSON.parse` method.
#
# Examples
#
# parser = JSON::Stream::Parser.new
# builder = JSON::Stream::Builder.new(parser)
# parser << '{... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | spec/parser_spec.rb | Ruby | mit | 201 | master | 30,812 | require 'json/stream'
require 'minitest/autorun'
describe JSON::Stream::Parser do
subject { JSON::Stream::Parser.new }
describe 'parsing a document' do
it 'rejects documents containing bad start character' do
expected = [:error]
assert_equal expected, events('a')
end
it 'rejects documents... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | spec/builder_spec.rb | Ruby | mit | 201 | master | 3,624 | require 'json/stream'
require 'minitest/autorun'
describe JSON::Stream::Builder do
let(:parser) { JSON::Stream::Parser.new }
subject { JSON::Stream::Builder.new(parser) }
it 'builds a false value' do
assert_nil subject.result
subject.start_document
subject.value(false)
assert_nil subject.result
... |
github | dgraham/json-stream | https://github.com/dgraham/json-stream | spec/buffer_spec.rb | Ruby | mit | 201 | master | 3,620 | require 'json/stream'
require 'minitest/autorun'
describe JSON::Stream::Buffer do
subject { JSON::Stream::Buffer.new }
it 'accepts single byte characters' do
assert_equal "", subject << ""
assert_equal "abc", subject << "abc"
assert_equal "\u0000abc", subject << "\u0000abc"
end
# The é character ... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | init.rb | Ruby | mit | 201 | master | 553 | require 'redmine'
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
require 'helpdesk_hooks'
require 'helpdesk_mailer'
require 'redmine_helpdesk/journal_patch'
require 'redmine_helpdesk/mail_handler_patch'
require 'redmine_helpdesk/mailer_patch'
Redmine::Plugin.register :redmine_helpdesk do
name 'Redmine helpdesk p... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/test_helper.rb | Ruby | mit | 201 | master | 794 | require "simplecov"
require "codeclimate-test-reporter"
SimpleCov.use_merging true
SimpleCov.merge_timeout 3600
SimpleCov.add_filter '/test/'
SimpleCov.add_filter 'init.rb'
SimpleCov.formatters = []
SimpleCov.start(CodeClimate::TestReporter.configuration.profile) do
root File.expand_path(File.dirname(__FILE__) + '/.... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/functional/issues_controller_with_helpdesk_test.rb | Ruby | mit | 201 | master | 4,050 | require File.dirname(__FILE__) + '/../test_helper'
class IssuesControllerWithHelpdeskTest < ActionController::TestCase
include Redmine::I18n
fixtures :all
def setup
User.current = nil
@controller = IssuesController.new
end
def test_render_send_to_owner_checkbox
issue = Issue.find(1)
@reque... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/unit/macro_expander_test.rb | Ruby | mit | 201 | master | 5,278 | require File.dirname(__FILE__) + '/../test_helper'
class MacroExpanderTest < ActionMailer::TestCase
include Redmine::I18n
self.use_transactional_tests = true
fixtures :all
def setup
ActionMailer::Base.deliveries.clear
Setting.host_name = 'mydomain.foo'
Setting.protocol = 'http'
Setting.plain... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/unit/journal_patch_test.rb | Ruby | mit | 201 | master | 2,054 | require File.dirname(__FILE__) + '/../test_helper'
class JournalPatchTest < ActiveSupport::TestCase
include Redmine::I18n
self.use_transactional_tests = true
fixtures :all
def setup
User.current = User.find(1)
end
def teardown
Setting.clear_cache
end
def test_notification_not_sent_when_sen... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/unit/mail_handler_patch_test.rb | Ruby | mit | 201 | master | 5,081 | require File.dirname(__FILE__) + '/../test_helper'
class MailHandlerPatchTest < ActiveSupport::TestCase
include Redmine::I18n
self.use_transactional_tests = true
fixtures :all
def setup
ActionMailer::Base.deliveries.clear
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
end
def... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | test/unit/helpdesk_mailer_test.rb | Ruby | mit | 201 | master | 5,866 | require File.dirname(__FILE__) + '/../test_helper'
class HelpdeskMailerTest < ActionMailer::TestCase
include Redmine::I18n
self.use_transactional_tests = true
fixtures :all
def setup
ActionMailer::Base.deliveries.clear
Setting.host_name = 'mydomain.foo'
Setting.protocol = 'http'
Setting.plai... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/009_create_custom_field_for_reopen_closed_issues_by_email.rb | Ruby | mit | 201 | master | 413 | class CreateCustomFieldForReopenClosedIssuesByEmail < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'reopen-issues-with',
:editable => true,
:visible => true,
:field_format => 'string')
c.type = 'ProjectCustomField' # cannot be set by mass assignement!
c.sa... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/008_create_custom_field_cc_handling.rb | Ruby | mit | 201 | master | 380 | class CreateCustomFieldCcHandling < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'cc-handling',
:editable => true,
:visible => true,
:field_format => 'bool')
c.type = 'ProjectCustomField' # cannot be set by mass assignement!
c.save
end
def self.down
... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/007_create_custom_copy_to_field.rb | Ruby | mit | 201 | master | 574 | class CreateCustomCopyToField < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'copy-to',
:editable => true,
:field_format => 'string')
c.type = 'IssueCustomField' # cannot be set by mass assignement!
c.save
Tracker.all.each do |t|
execute "INSERT INTO c... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/006_append_footer_to_first_reply.rb | Ruby | mit | 201 | master | 870 | class AppendFooterToFirstReply < ActiveRecord::Migration[5.2]
# Appends helpdesk-email-footer to helpdesk-first-reply to ensure backward
# compatibility for updaters. See https://github.com/jfqd/redmine_helpdesk/issues/52
def self.up
first_reply_cf_id = CustomField.find_by_name('helpdesk-first-reply').id
... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/005_add_treat_as_supportclient_to_anonymous.rb | Ruby | mit | 201 | master | 484 | class AddTreatAsSupportclientToAnonymous < ActiveRecord::Migration[5.2]
def self.up
anon_id = User.where(type: 'AnonymousUser').first.try(:id) ||
User.where('lastname LIKE ?', 'Anonymous').first.try(:id) ||
4
role = Role.where(builtin: anon_id).first
role.add_permission!(:treat... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/002_create_custom_fields_for_reply.rb | Ruby | mit | 201 | master | 794 | class CreateCustomFieldsForReply < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'helpdesk-first-reply',
:editable => true,
:visible => false, # do not show it on the project summary page
:field_format => 'text')
c.type = 'ProjectCustomField' # cannot ... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/001_create_custom_owner_email_field.rb | Ruby | mit | 201 | master | 873 | class CreateCustomOwnerEmailField < ActiveRecord::Migration[5.2]
def self.up
# fix PG:DuplicateColumn errors
# https://github.com/jfqd/redmine_helpdesk/issues/66
unless column_exists? :journals, :send_to_owner
add_column :journals, :send_to_owner, :boolean, :default => false
c = CustomField.ne... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/010_create_custom_field_for_reply_separator.rb | Ruby | mit | 201 | master | 605 | class CreateCustomFieldForReplySeparator < ActiveRecord::Migration[5.2]
def self.up
begin
c = CustomField.new(
:name => 'helpdesk-reply-separator',
:editable => true,
:visible => false, # do not show it on the project summary page
:field_format => 'string',
:... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/003_create_custom_field_for_sender_email.rb | Ruby | mit | 201 | master | 405 | class CreateCustomFieldForSenderEmail < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'helpdesk-sender-email',
:editable => true,
:visible => true,
:field_format => 'string')
c.type = 'ProjectCustomField' # cannot be set by mass assignement!
c.save
end
... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | db/migrate/004_create_custom_field_for_send_to_owner_default.rb | Ruby | mit | 201 | master | 484 | class CreateCustomFieldForSendToOwnerDefault < ActiveRecord::Migration[5.2]
def self.up
c = CustomField.new(
:name => 'helpdesk-send-to-owner-default',
:editable => true,
:visible => false, # do not show it on the project summary page
:field_format => 'bool')
c.type = 'Project... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/macro_expander.rb | Ruby | mit | 201 | master | 1,597 | module MacroExpander
def expand_macros(string, issue, journal)
e = Expander.new(string, issue, journal)
e.expand
end
class Expander
include Redmine::I18n
def initialize(string, issue, journal)
@string = string
@issue = issue
@journal = journal
end
def expand
unle... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/helpdesk_mailer.rb | Ruby | mit | 201 | master | 5,125 | #
# With Rails 3 mail is send with the mail method. Sadly redmine
# uses this method-name too in their mailer. This is the reason
# why we need our own Mailer class.
#
class HelpdeskMailer < ActionMailer::Base
helper :application
include Redmine::I18n
include MacroExpander
# set the hostname for url_for helpe... |
github | jfqd/redmine_helpdesk | https://github.com/jfqd/redmine_helpdesk | lib/helpdesk_hooks.rb | Ruby | mit | 201 | master | 1,996 | class HelpdeskHooks < Redmine::Hook::Listener
# render partial for 'Send mail to supportclient'
def view_issues_edit_notes_bottom(context={})
i = Issue.find(context[:issue].id)
c = CustomField.find_by_name('owner-email')
owner_email = i.custom_value_for(c).try(:value)
return if owner_email.blank?... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.