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 | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/notification_handler/notification_scopes.rb | Ruby | mit | 244 | main | 451 | # frozen_string_literal: true
require 'active_support'
module NotificationHandler
module NotificationScopes
extend ActiveSupport::Concern
included do
scope :read, -> { where(read: true) }
scope :unread, -> { where(read: false) }
include NotificationRenderer::NotificationScopes if defined... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/notification_handler/target.rb | Ruby | mit | 244 | main | 619 | # frozen_string_literal: true
require 'active_support'
module NotificationHandler
module Target
extend ActiveSupport::Concern
included do
def self.notification_target
has_many :notifications, as: :target, dependent: :destroy
include NotificationHandler::Target::InstanceMethods
... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/notification_handler/object.rb | Ruby | mit | 244 | main | 421 | # frozen_string_literal: true
require 'active_support'
module NotificationHandler
module Object
extend ActiveSupport::Concern
included do
def self.notification_object
has_many :belonging_notifications,
as: :object, class_name: 'Notification', dependent: :destroy
incl... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/notification_handler/configuration.rb | Ruby | mit | 244 | main | 523 | # frozen_string_literal: true
require_relative 'group'
module NotificationHandler
class << self
attr_writer :configuration
def configuration
@configuration ||= Configuration.new
end
end
def self.configure
yield configuration
end
class Configuration
attr_accessor :cache, :groups
... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/generators/templates/install/initializer.rb | Ruby | mit | 244 | main | 586 | # frozen_string_literal: true
NotificationHandler.configure do |config|
# Cache amount of unread and read notifications for notification targets.
# Learn more: https://github.com/jonhue/notifications-rails/tree/master/notification-handler#caching
# config.cache = false
# Groups are a powerful way to bulk-crea... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/lib/generators/notification_handler/install_generator.rb | Ruby | mit | 244 | main | 1,235 | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/migration'
module NotificationHandler
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root(File.join(File.dirname(__FILE__), '../templates/install'))
desc 'Install Notificatio... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-handler/app/models/notification_handler/notification.rb | Ruby | mit | 244 | main | 210 | # frozen_string_literal: true
module NotificationHandler
class Notification < ApplicationRecord
include NotificationHandler::NotificationLib
include NotificationHandler::NotificationScopes
end
end |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/notification-renderer.gemspec | Ruby | mit | 244 | main | 1,208 | # frozen_string_literal: true
version = File.read(File.expand_path('../VERSION', __dir__)).strip
Gem::Specification.new do |gem|
gem.name = 'notification-renderer'
gem.version = version
gem.platform = Gem::Platform::RUBY
gem.summary = 'Render your noti... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/app/helpers/notification_renderer_helper.rb | Ruby | mit | 244 | main | 2,403 | # frozen_string_literal: true
module NotificationRendererHelper
def render_notification(notification,
renderer: default_renderer,
attributes: nil,
notifications: nil)
notification.update(read: true) if auto_read
render(
parti... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/rails_helper.rb | Ruby | mit | 244 | main | 511 | # frozen_string_literal: true
require 'rails/all'
require 'factory_bot'
require 'rspec/rails'
ENV['RAILS_ENV'] = 'test'
require_relative 'support/rails_app/config/environment'
ActiveRecord::Migration.maintain_test_schema!
ActiveRecord::Schema.verbose = false
require_relative 'support/rails_app/db/schema'
require_r... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/notification_renderer_general_spec.rb | Ruby | mit | 244 | main | 567 | # frozen_string_literal: true
require_relative 'rails_helper'
RSpec.describe NotificationRenderer do
describe 'baseline' do
it 'only loaded the absolute minimum dependencies ' \
'so we can test in isolation' do
expect(defined?(NotificationHandler)).to eq 'constant'
expect(defined?(Notificati... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/helpers/notification_renderer_helper_spec.rb | Ruby | mit | 244 | main | 3,199 | # frozen_string_literal: true
require_relative '../rails_helper'
def create_title_and_content_notification(title, content)
Notification.create(type: 'title_and_content',
metadata: { title: title, content: content })
end
notification1 = create_title_and_content_notification('title1', 'content1... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/support/rails_app/db/schema.rb | Ruby | mit | 244 | main | 1,385 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/support/rails_app/config/environment.rb | Ruby | mit | 244 | main | 297 | # frozen_string_literal: true
# Load the Rails application.
require_relative 'application'
require_relative '../../../../../notification-handler/lib/notification-handler'
require_relative '../../../../lib/notification-renderer'
# Initialize the Rails application.
Rails.application.initialize! |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/spec/lib/notification_renderer/configuration_spec.rb | Ruby | mit | 244 | main | 658 | # frozen_string_literal: true
require_relative '../../../../spec/spec_helper'
require_relative '../../../lib/notification_renderer/configuration'
RSpec.describe NotificationRenderer::Configuration do
let(:configuration) { NotificationRenderer.configuration }
it 'allows configuring the gem' do
NotificationRen... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/notification-renderer.rb | Ruby | mit | 244 | main | 318 | # frozen_string_literal: true
module NotificationRenderer
require_relative 'notification_renderer/configuration'
require_relative 'notification_renderer/engine'
autoload :NotificationLib, 'notification_renderer/notification_lib'
autoload :NotificationScopes, 'notification_renderer/notification_scopes'
end |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/notification_renderer/notification_lib.rb | Ruby | mit | 244 | main | 1,156 | # frozen_string_literal: true
require 'notification-handler'
require 'active_support'
module NotificationRenderer
module NotificationLib
extend ActiveSupport::Concern
module ClassMethods
def grouping(group_by)
notifications = all
group_by.each do |method|
notifications = rec... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/notification_renderer/configuration.rb | Ruby | mit | 244 | main | 457 | # frozen_string_literal: true
module NotificationRenderer
class << self
attr_writer :configuration
def configuration
@configuration ||= Configuration.new
end
end
def self.configure
yield configuration
end
class Configuration
attr_accessor :auto_read, :default_renderer, :default_t... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/notification_renderer/notification_scopes.rb | Ruby | mit | 244 | main | 511 | # frozen_string_literal: true
require 'notification-handler'
require 'active_support'
module NotificationRenderer
module NotificationScopes
extend ActiveSupport::Concern
module ClassMethods
def method_missing(method, *args)
if method.to_s[/(.+)_type/]
where(type: $1.singularize.clas... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/generators/notification_renderer/install_generator.rb | Ruby | mit | 244 | main | 1,227 | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/migration'
module NotificationRenderer
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root(File.join(File.dirname(__FILE__), '../templates/install'))
desc 'Install Notificati... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-renderer/lib/generators/notification_renderer/type_generator.rb | Ruby | mit | 244 | main | 970 | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/migration'
module NotificationRenderer
class TypeGenerator < Rails::Generators::Base
source_root(File.join(File.dirname(__FILE__), '../templates/type'))
desc 'Create a new notification type'
class_option :type,
... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/notification-settings.gemspec | Ruby | mit | 244 | main | 1,544 | # frozen_string_literal: true
version = File.read(File.expand_path('../VERSION', __dir__)).strip
Gem::Specification.new do |gem|
gem.name = 'notification-settings'
gem.version = version
gem.platform = Gem::Platform::RUBY
gem.summary = 'Integrates with ... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/app/models/notification_settings/subscription.rb | Ruby | mit | 244 | main | 368 | # frozen_string_literal: true
module NotificationSettings
class Subscription < ApplicationRecord
self.table_name = 'notification_settings_subscriptions'
include NotificationSettings::Settings
belongs_to :subscriber, polymorphic: true
belongs_to :subscribable, polymorphic: true
has_many :notifi... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification-settings.rb | Ruby | mit | 244 | main | 876 | # frozen_string_literal: true
module NotificationSettings
require_relative 'notification_settings/configuration'
require_relative 'notification_settings/engine'
autoload :Target, 'notification_settings/target'
autoload :Subscriber, 'notification_settings/subscriber'
autoload :Subscribable, 'notification_se... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/notification_lib.rb | Ruby | mit | 244 | main | 5,436 | # frozen_string_literal: true
require 'notification-handler'
require 'active_support'
module NotificationSettings
module NotificationLib
extend ActiveSupport::Concern
included do
before_create :validate_create
validates :category, inclusion: {
in: NotificationSettings.configuration.cat... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/configuration.rb | Ruby | mit | 244 | main | 841 | # frozen_string_literal: true
module NotificationSettings
class << self
attr_writer :configuration
def configuration
@configuration ||= Configuration.new
end
end
def self.configure
yield configuration
end
class Configuration
attr_accessor :categories, :default_category, :do_not_d... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/settings.rb | Ruby | mit | 244 | main | 529 | # frozen_string_literal: true
require 'active_support'
require 'hashie'
module NotificationSettings
module Settings
extend ActiveSupport::Concern
included do
before_validation :build_settings
serialize :settings, Hashie::Mash
include NotificationSettings::Settings::InstanceMethods
e... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/subscriber.rb | Ruby | mit | 244 | main | 857 | # frozen_string_literal: true
require 'active_support'
module NotificationSettings
module Subscriber
extend ActiveSupport::Concern
included do
has_many :notification_subscribables,
as: :subscriber,
class_name: 'NotificationSettings::Subscription',
dependen... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/category_preferences_form.rb | Ruby | mit | 244 | main | 284 | # frozen_string_literal: true
require 'active_model'
module NotificationSettings
class CategoryPreferencesForm
include ActiveModel::Model
NotificationSettings.configuration.categories.each do |category|
attribute category, :boolean, default: true
end
end
end |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/target.rb | Ruby | mit | 244 | main | 258 | # frozen_string_literal: true
require 'active_support'
module NotificationSettings
module Target
extend ActiveSupport::Concern
included do
include NotificationSettings::Settings
include NotificationSettings::Status
end
end
end |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/delivery_method_preferences_form.rb | Ruby | mit | 244 | main | 383 | # frozen_string_literal: true
require 'active_model'
module NotificationSettings
class DeliveryMethodPreferencesForm
include ActiveModel::Model
attribute :enabled, :boolean, default: true
NotificationPusher.configuration.delivery_methods
.each_key do |delivery_method|
attrib... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/subscribable.rb | Ruby | mit | 244 | main | 1,233 | # frozen_string_literal: true
require 'active_support'
module NotificationSettings
module Subscribable
extend ActiveSupport::Concern
included do
has_many :notification_subscribers,
as: :subscribable,
class_name: 'NotificationSettings::Subscription',
depend... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/notification_scopes.rb | Ruby | mit | 244 | main | 523 | # frozen_string_literal: true
require 'notification-handler'
require 'active_support'
module NotificationSettings
module NotificationScopes
extend ActiveSupport::Concern
module ClassMethods
def method_missing(method, *args)
if method.to_s[/(.+)_category/]
where(category: $1.singular... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/notification_settings/status.rb | Ruby | mit | 244 | main | 1,353 | # frozen_string_literal: true
require 'active_support'
module NotificationSettings
module Status
extend ActiveSupport::Concern
included do
validates :status,
inclusion: { in: NotificationSettings.configuration.statuses }
include NotificationSettings::Status::InstanceMethods
... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/generators/templates/install/initializer.rb | Ruby | mit | 244 | main | 1,269 | # frozen_string_literal: true
NotificationSettings.configure do |config|
# An array of all notification categories. Takes an array of symbols.
# config.categories = [:notification]
# Choose your default notification category. Takes a symbol.
# config.default_category = :notification
### STATUS ###
# Tim... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/lib/generators/notification_settings/install_generator.rb | Ruby | mit | 244 | main | 1,127 | # frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/migration'
module NotificationSettings
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root(File.join(File.dirname(__FILE__), '../templates/install'))
desc 'Install Notificati... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/notification_settings_general_spec.rb | Ruby | mit | 244 | main | 567 | # frozen_string_literal: true
require_relative 'rails_helper'
RSpec.describe NotificationSettings do
describe 'baseline' do
it 'only loaded the absolute minimum dependencies ' \
'so we can test in isolation' do
expect(defined?(NotificationHandler)).to eq 'constant'
expect(defined?(Notificati... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/lib/notification_settings/configuration_spec.rb | Ruby | mit | 244 | main | 1,127 | # frozen_string_literal: true
require_relative '../../../../spec/spec_helper'
require_relative '../../../lib/notification_settings/configuration'
RSpec.describe NotificationSettings::Configuration do
let(:configuration) { NotificationSettings.configuration }
it 'allows configuring the gem' do
NotificationSet... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/lib/notification_settings/subscribable_spec.rb | Ruby | mit | 244 | main | 1,144 | # frozen_string_literal: true
require_relative '../../rails_helper'
RSpec.describe NotificationSettings::Subscribable do
let(:recipe) { create(:recipe) }
let(:user1) { create(:user) }
let(:user2) { create(:user) }
describe '#notify_subscribers' do
before do
user1.subscribe(recipe)
user2.sub... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/lib/notification_settings/subscriber_spec.rb | Ruby | mit | 244 | main | 479 | # frozen_string_literal: true
require_relative '../../rails_helper'
RSpec.describe NotificationSettings::Subscriber do
let(:user) { build_stubbed(:user) }
let(:recipe) { build_stubbed(:recipe) }
it 'subscribe' do
user.subscribe(recipe)
expect(user.notification_subscribables.present?).to be true
end... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/lib/notification_settings/notification_lib_spec.rb | Ruby | mit | 244 | main | 3,350 | # frozen_string_literal: true
require_relative '../../rails_helper'
RSpec.describe NotificationSettings::NotificationLib do
let(:notification) { build_stubbed(:notification, category: :my_category) }
let(:user) { notification.target }
let(:settings) { user.settings }
context 'with persisted user'... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/support/rails_app/db/schema.rb | Ruby | mit | 244 | main | 2,150 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/support/rails_app/config/application.rb | Ruby | mit | 244 | main | 604 | # frozen_string_literal: true
require_relative 'boot'
require 'rails/all'
module RailsApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Settings in config/environments/* take precedence over those specified... |
github | jonhue/notifications-rails | https://github.com/jonhue/notifications-rails | notification-settings/spec/support/rails_app/config/environment.rb | Ruby | mit | 244 | main | 297 | # frozen_string_literal: true
# Load the Rails application.
require_relative 'application'
require_relative '../../../../../notification-handler/lib/notification-handler'
require_relative '../../../../lib/notification-settings'
# Initialize the Rails application.
Rails.application.initialize! |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | ferry.gemspec | Ruby | mit | 244 | master | 1,750 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ferry/version'
Gem::Specification.new do |spec|
spec.name = "ferry"
spec.version = Ferry::VERSION
spec.authors = ["Anthony Corletti", "Logan Watanabe", "Larry Heimann"]... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry.rb | Ruby | mit | 244 | master | 318 | require 'active_record'
require 'csv'
require 'enumerator'
require 'ferry/exporter'
require 'ferry/dumper'
require 'ferry/filler'
require 'ferry/importer'
require 'ferry/utilities'
require 'ferry/version'
require 'highline/import'
require 'optparse'
require 'progressbar'
require 'pp'
require 'yaml'
module Ferry
end |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dsl.rb | Ruby | mit | 244 | master | 1,365 | require 'etc'
require 'ferry/dsl/task_enhancements'
require 'ferry/dsl/paths'
require 'ferry/dsl/stages'
require 'ferry/dsl/env'
require 'ferry/configuration/filter'
module Ferry
module DSL
include TaskEnhancements
include Env
include Paths
include Stages
def invoke(task, *args)
Rake::Task... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/i18n.rb | Ruby | mit | 244 | master | 325 | require 'i18n'
en = {
starting: 'Starting',
installing: 'Installing',
set_sail: 'Set Sail!',
moving: 'Moving',
completed: 'Completed'
},
error: 'Some error'
}
}
I18n.backend.store_translations(:en, { ferry: en })
if I18n.respond_to?(:enforce_available_locales=)
I18n.enforce_available_locales = true... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/importer.rb | Ruby | mit | 244 | master | 2,654 | require_relative 'utilities'
module Ferry
# TODO
# things to consider for importer
# - columns not matching and handling those errors
class Importer < Utilities
def row_sql_format(hash, columns, adapter)
values = hash.values_at(*columns)
values.map! do |value|
if(adapter=="mysql2" && (... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/configuration.rb | Ruby | mit | 244 | master | 3,258 | require_relative 'configuration/filter'
require_relative 'configuration/question'
require_relative 'configuration/server'
require_relative 'configuration/servers'
module Ferry
class Configuration
def initialize(config = nil)
@config ||= config
end
def self.env
@env ||= new
end
def ... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/utilities.rb | Ruby | mit | 244 | master | 982 | module Ferry
class Utilities
def check_valid_db(db)
%w[sqlite3 postgresql mysql2].include?(db) ? true : false
end
def check_valid_filetype(filepath)
%w[csv json sql yml].include?(filepath.split('.').last) ? true : false
end
def db_connect(environment)
db_config = YAML::load(IO... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/filler.rb | Ruby | mit | 244 | master | 991 | require_relative 'utilities'
module Ferry
class Filler < Utilities
def fill(environment, content)
# check to make sure db exists
# drop database
# prompt user to confirm that they will erase the current env db and refill
# fill
@dbadapter = db_connect(environment)
@dbenv = en... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/exporter.rb | Ruby | mit | 244 | master | 5,497 | require_relative 'utilities'
module Ferry
class Exporter < Utilities
def to_csv(environment, model)
db_type = db_connect(environment)
FileUtils.mkdir "db" unless Dir["db"].present?
FileUtils.mkdir "db/csv" unless Dir["db/csv"].present?
homedir = "db/csv/#{environment}"
FileUtils.mk... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dumper.rb | Ruby | mit | 244 | master | 1,056 | require_relative 'utilities'
module Ferry
class Dumper < Utilities
def dump(environment)
@dbadapter = db_connect(environment)
@dbenv = environment
@dbname = YAML::load(IO.read("config/database.yml"))[@dbenv]["database"]
@outfile_path = "db/sql_dumps/#{@dbname}/#{@dbadapter}/#{@dbenv}/dum... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/setup.rb | Ruby | mit | 244 | master | 420 | include Ferry::DSL
namespace :load do
task :defaults do
load 'ferry/defaults.rb'
end
end
stages.each do |stage|
Rake::Task.define_task(stage) do
set(:stage, stage.to_sym)
invoke 'load:defaults'
load deploy_config_path
load stage_config_path.join("#{stage}.rb")
load "ferry/#{fetch(:scm)}... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/configuration/filter.rb | Ruby | mit | 244 | master | 1,599 | require 'ferry/configuration'
module Ferry
class Configuration
class Filter
def initialize type, values = nil
raise "Invalid filter type #{type}" unless [:host,:role].include? type
av = Array(values).dup
@mode = case
when av.size == 0 then :none
when ... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/configuration/server.rb | Ruby | mit | 244 | master | 2,643 | require 'set'
module Ferry
class Configuration
class Server < SSHKit::Host
extend Forwardable
def_delegators :properties, :roles, :fetch, :set
def self.[](host)
host.is_a?(Server) ? host : new(host)
end
def add_roles(roles)
Array(roles).each { |role| add_role(role) ... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/configuration/question.rb | Ruby | mit | 244 | master | 1,014 | module Ferry
module Configuration
module Question
def initialize(key, default, options = {})
@key, @default, @options = key, default, options
end
def call
ask_question
value_or_default
end
private
attr_reader :key, :default, :options
def ask_que... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/configuration/servers.rb | Ruby | mit | 244 | master | 1,845 | require 'set'
require 'ferry/configuration'
require 'ferry/configuration/filter'
module Ferry
class Configuration
class Servers
include Enumerable
def add_host(host, properties={})
new_host = Server[host]
if server = servers.find { |s| s.matches? new_host }
server.user = ne... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/tasks/framework.rake | Ruby | mit | 244 | master | 933 | namespace :deploy do
desc "Preparing ferry for deployment."
task :starting do
end
desc 'Started'
task :started do
end
desc 'Revert database to previous release.'
task :reverting do
end
desc 'Reverted'
task :reverted do
end
desc 'Finish the deployment, cleaning up.'
task :finishing do
... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/tasks/install.rake | Ruby | mit | 244 | master | 1,319 | require 'erb'
require 'pathname'
desc 'Install Ferry, ferry install STAGES=test,development,production'
task :install do
envs = ENV['STAGES'] || 'test,development,production'
tasks_dir = Pathname.new('lib/ferry/tasks')
config_dir = Pathname.new('config')
deploy_dir = config_dir.join('deploy_ferry')
deploy_r... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/tasks/deploy.rake | Ruby | mit | 244 | master | 6,217 | namespace :deploy do
task :starting do
invoke 'deploy:check'
invoke 'deploy:set_previous_revision'
end
task :updating => :new_release_path do
invoke "#{scm}:create_release"
invoke "deploy:set_current_revision"
invoke 'deploy:symlink:shared'
end
task :reverting do
invoke 'deploy:reve... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dsl/env.rb | Ruby | mit | 244 | master | 1,548 | module Ferry
module DSL
module Env
def configure_backend
env.configure_backend
end
def fetch(key, default=nil, &block)
env.fetch(key, default, &block)
end
def any?(key)
value = fetch(key)
if value && value.respond_to?(:any?)
value.any?
... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dsl/stages.rb | Ruby | mit | 244 | master | 299 | module Ferry
module DSL
module Stages
def stages
Dir[stage_definitions].map { |f| File.basename(f, '.rb') }
end
def stage_definitions
stage_config_path.join('*.rb')
end
def stage_set?
!!fetch(:stage, false)
end
end
end
end |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dsl/task_enhancements.rb | Ruby | mit | 244 | master | 1,564 | require 'ferry/upload_task'
module Ferry
module TaskEnhancements
def before(task, prerequisite, *args, &block)
prerequisite = Rake::Task.define_task(prerequisite, *args, &block) if block_given?
Rake::Task[task].enhance [prerequisite]
end
def after(task, post_task, *args, &block)
Rake::... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | lib/ferry/dsl/paths.rb | Ruby | mit | 244 | master | 2,335 | require 'pathname'
module Ferry
module DSL
module Paths
def deploy_to
fetch(:deploy_to)
end
def deploy_path
Pathname.new(deploy_to)
end
def current_path
deploy_path.join('current')
end
def releases_path
deploy_path.join('releases')
... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/ferry_spec.rb | Ruby | mit | 244 | master | 311 | # please note that running rspec spec/ferry_spec.rb will assumes you have ...
# a pg and mysql db named ferry_test on your local machine
require 'spec_helper'
require 'tests/utilities_tests'
require 'tests/exporter_tests'
require 'tests/importer_tests'
require 'tests/dumper_tests'
require 'tests/filler_tests' |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/contexts.rb | Ruby | mit | 244 | master | 327 | require 'sets/category_context'
require 'sets/product_context'
require 'sets/cart_context'
require 'sets/order_context'
module Contexts
def self.setup
create_categories
create_products
create_carts
create_orders
end
def self.teardown
delete_orders
delete_carts
delete_products
delete_categories
e... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/spec_helper.rb | Ruby | mit | 244 | master | 781 | require 'ferry'
require 'fileutils'
require 'factory_girl'
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
load File.dirname(__FILE__) + "/support/factories.rb"
require "logger"
require "contexts.rb"
FileUtils.mkdir_p 'log'
ActiveRecord::Base.logger = Logger.new("log/test.log")
ActiveRecord:... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/sets/product_context.rb | Ruby | mit | 244 | master | 3,559 | def create_products
# assumes create_categories prior
@food1 = FactoryGirl.create(:product, category: @food)
@food2 = FactoryGirl.create(:product, category: @food, name: "potato", price: 0.69, sales_start_date: nil, sales_end_date: nil, flash_sale_time: nil, on_sale: false, stock: 50)
@food3 = FactoryGirl.creat... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/sets/order_context.rb | Ruby | mit | 244 | master | 3,412 | def create_orders
# assumes create_products and create_carts prior
@order1 = FactoryGirl.create(:order, product: @toy1, cart: @cart1, quantity: 1, date: Date.new(2014, 1, 23))
@order2 = FactoryGirl.create(:order, product: @toy2, cart: @cart2, quantity: 22, date: Date.new(2014, 4, 5))
@order3 = FactoryGirl.creat... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/sets/category_context.rb | Ruby | mit | 244 | master | 760 | def create_categories
@food = FactoryGirl.create(:category)
@cleaning = FactoryGirl.create(:category, name: "Cleaning Supplies", description: "Household cleaning products.")
@antiques = FactoryGirl.create(:category, name: "Antiques", active: false, description:"No longer carried.")
@toilet = FactoryGirl.create(... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/sets/cart_context.rb | Ruby | mit | 244 | master | 2,170 | def create_carts
@cart1 = FactoryGirl.create(:cart, email: "abby@example.com")
@cart2 = FactoryGirl.create(:cart, email: "bob@example.com")
@cart3 = FactoryGirl.create(:cart, email: "chris@example.com")
@cart4 = FactoryGirl.create(:cart, email: "david@example.com")
@cart5 = FactoryGirl.create(:cart, email: "e... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/support/factories.rb | Ruby | mit | 244 | master | 586 | FactoryGirl.define do
factory :product do
name "Candy Bar"
price 1.29
sales_start_date Date.new(2013,7,14)
sales_end_date nil
flash_sale_time Time.new(2016, 10, 31, 16, 20, 0)
on_sale false
stock 120
end
factory :category do
name "Food"
description "Any item that can b... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/support/schema.rb | Ruby | mit | 244 | master | 968 | ActiveRecord::Schema.define do
create_table :products, :force=>true do |t|
t.column :name, :string, :null => false
t.column :price, :decimal
t.column :category_id, :integer
t.column :sales_start_date, :datetime
t.column :sales_end_date, :datetime
t.column :flash_sale_time, :time
t.column :... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/tests/dumper_tests.rb | Ruby | mit | 244 | master | 1,690 | dumper = Ferry::Dumper.new
Dir.chdir("spec") unless Dir.pwd.split('/').last == "spec"
# TODO :: refactor testing where you can test that the dumpfile is correct
describe "dumper" do
describe "sqlite3" do
before(:all) do
connect("sqlite3")
Contexts.setup
end
after(:all) do
Contexts.tea... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/tests/utilities_tests.rb | Ruby | mit | 244 | master | 1,156 | utils = Ferry::Utilities.new
Dir.chdir("spec") unless Dir.pwd.split('/').last == "spec"
describe("utility functions") do
describe "#db_connect" do
it "#sqlite3" do
expect{utils.db_connect("sqlite3")}.not_to raise_error
expect(ActiveRecord::Base.connection.adapter_name).to eql('SQLite')
end
... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/tests/exporter_tests.rb | Ruby | mit | 244 | master | 6,909 | exporter = Ferry::Exporter.new
Dir.chdir("spec") unless Dir.pwd.split('/').last == "spec"
# TODO: test db func expo
describe "exporting" do
describe "sqlite3 db" do
before(:all) do
connect("sqlite3")
Contexts.setup
end
after(:all) do
Contexts.teardown
FileUtils.rm_rf('db')
e... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/tests/importer_tests.rb | Ruby | mit | 244 | master | 8,165 | importer = Ferry::Importer.new
Dir.chdir("spec") unless Dir.pwd.split('/').last == "spec"
describe "import" do
describe "sqlite3 db" do
before(:all) do
connect("sqlite3")
Contexts.setup
end
after(:all) do
Contexts.teardown
Category.delete_all
end
it "should import a valid csv into ActiveRecor... |
github | cmu-is-projects/ferry | https://github.com/cmu-is-projects/ferry | spec/tests/filler_tests.rb | Ruby | mit | 244 | master | 2,899 | filler = Ferry::Filler.new
Dir.chdir("spec") unless Dir.pwd.split('/').last == "spec"
# TODO
# given some sql file
# make sure that we successfully load (fill) that database with the sql file's content
# but how to measure that it was a success or not?
# number of records?
# content?
# queries to see if things match
... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | Rakefile | Ruby | mit | 244 | master | 378 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require "rake"
require "rdoc/task"
require "rspec"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = "spec/**/*_spec.rb"
end
RSpec::Core::RakeTask.new('spec:progress') do |spec|
spec.rspec_opts = %w(--format progress)
spec.... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | css_sprite.gemspec | Ruby | mit | 244 | master | 968 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/css_sprite/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Richard Huang"]
gem.email = ["flyerhzm@gmail.com"]
gem.description = %q{css_sprite is a rails plugin/gem to generate css sprite image automatically.}
gem.sum... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | lib/css_sprite.rb | Ruby | mit | 244 | master | 233 | require 'rake'
require "css_sprite/version"
unless Rake::Task.task_defined? "css_sprite:build"
load File.join(File.dirname(__FILE__), '..', 'tasks', 'css_sprite_tasks.rake')
end
module CssSprite
require 'css_sprite/sprite'
end |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | lib/automatic.rb | Ruby | mit | 244 | master | 254 | require 'rubygems'
require File.join(File.dirname(__FILE__), 'css_sprite/sprite.rb')
# We need Rails.root, but not require 'rails', so hack it
class Rails
def self.root
Dir.pwd
end
end
sprite = Sprite.new
loop do
sleep 1
sprite.check
end |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | lib/css_sprite/sprite.rb | Ruby | mit | 244 | master | 10,995 | require 'find'
require 'mini_magick'
require 'yaml'
require 'enumerator'
class Sprite
def initialize(options={})
base_dir = Dir.pwd
if File.exist?(File.join(base_dir, 'config/css_sprite.yml'))
@config = YAML::load_file(File.join(base_dir, 'config/css_sprite.yml'))
else
@config = options
... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | tasks/css_sprite_tasks.rake | Ruby | mit | 244 | master | 1,826 | require 'rbconfig'
namespace :css_sprite do
desc "build css sprite image once"
task :build do
require File.join(File.dirname(__FILE__), '../lib/css_sprite/sprite.rb')
Sprite.new.build
end
desc "restart css sprite server"
task :restart => [:stop, :start]
desc "start css sprite server"
task :star... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | spec/spec_helper.rb | Ruby | mit | 244 | master | 565 | require 'date'
require 'mocha/api'
require 'coveralls'
Coveralls.wear!
class Dir
def self.pwd
File.dirname(__FILE__)
end
end
IMAGE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'app/assets/images'))
STYLESHEET_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'app/assets/stylesheets'))
re... |
github | flyerhzm/css_sprite | https://github.com/flyerhzm/css_sprite | spec/css_sprite/sprite_spec.rb | Ruby | mit | 244 | master | 7,038 | require 'spec_helper'
RSpec.describe Sprite do
before(:context) do
@sprite = Sprite.new
@directory_path = File.join(IMAGE_PATH, 'css_sprite')
end
describe "build" do
it "should build css_sprite image and css" do
Sprite.any_instance.expects(:system).with("optipng -o 1 #{IMAGE_PATH}/css_sprite.p... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | Rakefile | Ruby | mit | 244 | main | 1,361 | # frozen_string_literal: true
require "rake"
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubocop/rake_task"
namespace :spec do
RSpec::Core::RakeTask.new(:unit) do |task|
file_list = FileList["spec/**/*_spec.rb"]
file_list = file_list.exclude("spec/{integration,isolation}/**/*_spec.rb... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | Gemfile | Ruby | mit | 244 | main | 941 | # frozen_string_literal: true
source "http://rubygems.org"
gemspec
eval_gemfile "Gemfile.devtools"
unless ENV["CI"]
gem "byebug", platforms: :mri
gem "yard"
gem "yard-junk"
end
if ENV["RACK_MATRIX_VALUE"]
gem "rack", ENV["RACK_MATRIX_VALUE"]
end
gem "hanami-utils", github: "hanami/utils", branch: "main"
... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | hanami-action.gemspec | Ruby | mit | 244 | main | 1,612 | # frozen_string_literal: true
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "hanami/action/version"
Gem::Specification.new do |spec|
spec.name = "hanami-action"
spe... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami-controller.rb | Ruby | mit | 244 | main | 231 | # frozen_string_literal: true
require_relative "hanami/action"
warn(
"`require \"hanami-controller\"` is deprecated and will be removed in Hanami 3.1. " \
"Use `require \"hanami-action\"` instead.",
category: :deprecated
) |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/controller.rb | Ruby | mit | 244 | main | 397 | # frozen_string_literal: true
require "hanami/action"
# Hanami
#
# @since 0.1.0
module Hanami
# A set of logically grouped actions
#
# @see Hanami::Action
#
# @since 0.1.0
# @api public
module Controller
end
end
warn(
"`require \"hanami/controller\"` is deprecated and will be removed in Hanami 3.1.... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action.rb | Ruby | mit | 244 | main | 17,713 | # frozen_string_literal: true
require "dry/configurable"
require "hanami/utils"
require "hanami/utils/callbacks"
require "hanami/utils/kernel"
require "hanami/utils/string"
require "rack"
require "rack/utils"
require "hanami/action/rack_utils"
require "zeitwerk"
require_relative "action/constants"
require_relative "a... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/http/status.rb | Ruby | mit | 244 | main | 4,287 | # frozen_string_literal: true
require "rack/utils"
module Hanami
# @since 0.1.0
# @api private
module Http
# An HTTP status
#
# @since 0.1.0
# @api private
class Status
# A set of standard codes and messages for HTTP statuses
#
# @since 0.1.0
# @api private
ALL ... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action/response.rb | Ruby | mit | 244 | main | 14,295 | # frozen_string_literal: true
require "rack"
require "rack/response"
require "hanami/utils/kernel"
require_relative "errors"
module Hanami
class Action
# The HTTP response for an action, given to {Action#handle}.
#
# Inherits from `Rack::Response`, providing compatibility with Rack functionality.
#
... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action/config.rb | Ruby | mit | 244 | main | 4,624 | # frozen_string_literal: true
require "dry/configurable"
module Hanami
class Action
# Config for `Hanami::Action` classes.
#
# @see Hanami::Action.config
#
# @api public
# @since 2.0.0
class Config < Dry::Configurable::Config
# Default public directory
#
# This serves a... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action/body_parser.rb | Ruby | mit | 244 | main | 3,665 | # frozen_string_literal: true
require "rack"
require "hanami/utils/hash"
module Hanami
class Action
# Parses request bodies based on the action's accepted formats.
#
# @api private
module BodyParser
FALLBACK_KEY = :_
class << self
# rubocop:disable Metrics/AbcSize, Metrics/Perce... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action/halt.rb | Ruby | mit | 244 | main | 353 | # frozen_string_literal: true
require "hanami/http/status"
module Hanami
class Action
# @api private
# @since 2.0.0
module Halt
# @api private
# @since 2.0.0
def self.call(status, body = nil)
code, message = Http::Status.for_code(status)
throw :halt, [code, body || mess... |
github | hanami/hanami-action | https://github.com/hanami/hanami-action | lib/hanami/action/cache.rb | Ruby | mit | 244 | main | 697 | # frozen_string_literal: true
module Hanami
class Action
# Cache type API
#
# @since 0.3.0
#
# @see Hanami::Action::Cache::ClassMethods#cache_control
# @see Hanami::Action::Cache::ClassMethods#expires
# @see Hanami::Action::Cache::ClassMethods#fresh
module Cache
# Override Ruby'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.