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
ghempton/camcorder
https://github.com/ghempton/camcorder
spec/spec_helper.rb
Ruby
mit
86
master
210
require 'json' require 'rspec' require 'camcorder' require 'camcorder/rspec' require 'support/test_object' require 'support/test_object2' require 'byebug' Camcorder.config.recordings_dir = 'spec/recordings'
github
ghempton/camcorder
https://github.com/ghempton/camcorder
spec/support/test_object.rb
Ruby
mit
86
master
262
class TestObject attr_reader :count def initialize() @count = 0 end def simple_method ['A', 'B', 'C'] end def method_with_side_effects @count += 1 end def broke_method raise StandardError.new('errorz') end end
github
ghempton/camcorder
https://github.com/ghempton/camcorder
spec/camcorder/proxy_spec.rb
Ruby
mit
86
master
1,508
require 'spec_helper' describe Camcorder::Proxy do subject{ Camcorder::Proxy.new(Camcorder.default_recorder, TestObject) } context 'when recording exists' do it 'should not call methods on actual instance' do expect_any_instance_of(TestObject).to_not receive(:simple_method) expect(...
github
ghempton/camcorder
https://github.com/ghempton/camcorder
spec/camcorder/recorder_spec.rb
Ruby
mit
86
master
3,380
require 'spec_helper' describe Camcorder::Recorder do subject{ Camcorder::Recorder.new(filename) } describe '.transaction' do let(:key) { 'key' } context 'when recording exists' do let(:filename) { 'spec/fixtures/should_exist.yml'} it 'should return recorded value' do subject.tra...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
acts_as_recursive_tree.gemspec
Ruby
mit
86
main
1,934
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'acts_as_recursive_tree/version' Gem::Specification.new do |spec| spec.name = 'acts_as_recursive_tree' spec.version = ActsAsRecursiveTree::VERSION s...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
Rakefile
Ruby
mit
86
main
280
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: [:spec] desc 'Deletes temporary files' task :clean_tmp_files do %w[db.log test.sqlite3].each do |file| FileUtils.rm_f(file) end end
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
Appraisals
Ruby
mit
86
main
524
# frozen_string_literal: true appraise 'ar-70' do gem 'activerecord', '~> 7.0' gem 'activesupport', '~> 7.0' end appraise 'ar-71' do gem 'activerecord', '~> 7.1' gem 'activesupport', '~> 7.1' end appraise 'ar-72' do gem 'activerecord', '~> 7.2' gem 'activesupport', '~> 7.2' end appraise 'ar-80' do gem...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/spec_helper.rb
Ruby
mit
86
main
5,442
# frozen_string_literal: true $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'active_record' require 'acts_as_recursive_tree' require_relative 'db/database' require 'databa...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/support/tree_methods.rb
Ruby
mit
86
main
676
# frozen_string_literal: true # Helper methods for simple tree creation module TreeMethods def create_tree(max_level, current_level: 0, node: nil, create_node_info: false, stop_at: -1) node ||= Node.create!(name: 'root') 1.upto(max_level - current_level) do |index| child = node.children.create!(name: ...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/support/shared_examples/builders.rb
Ruby
mit
86
main
3,538
# frozen_string_literal: true RSpec.shared_context 'with enforced ordering setup' do let(:ordering) { false } include_context 'with base_setup' do let(:proc) { ->(config) { config.ensure_ordering! } } end end RSpec.shared_context 'with base_setup' do subject(:query) { builder.build.to_sql } let(:model_...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/acts_as_recursive_tree/builders/ancestors_spec.rb
Ruby
mit
86
main
420
# frozen_string_literal: true require 'spec_helper' RSpec.describe ActsAsRecursiveTree::Builders::Ancestors do context 'without additional setup' do it_behaves_like 'build recursive query' it_behaves_like 'ancestor query' include_context 'with ordering' end context 'with options' do include_con...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/acts_as_recursive_tree/builders/leaves_spec.rb
Ruby
mit
86
main
453
# frozen_string_literal: true require 'spec_helper' RSpec.describe ActsAsRecursiveTree::Builders::Leaves do context 'without additional setup' do it_behaves_like 'build recursive query' it_behaves_like 'descendant query' include_context 'without ordering' end context 'with options' do include_c...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/acts_as_recursive_tree/builders/descendants_spec.rb
Ruby
mit
86
main
457
# frozen_string_literal: true require 'spec_helper' RSpec.describe ActsAsRecursiveTree::Builders::Descendants do context 'without additional setup' do it_behaves_like 'build recursive query' it_behaves_like 'descendant query' include_context 'without ordering' end context 'with options' do incl...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/acts_as_recursive_tree/preloaders/descendants_spec.rb
Ruby
mit
86
main
1,120
# frozen_string_literal: true require 'spec_helper' RSpec.describe ActsAsRecursiveTree::Preloaders::Descendants do include TreeMethods let(:preloader) { described_class.new(root.reload, includes: included_associations) } let(:included_associations) { nil } let(:root) { create_tree(2, create_node_info: true) ...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/acts_as_recursive_tree/options/values_spec.rb
Ruby
mit
86
main
2,589
# frozen_string_literal: true require 'spec_helper' RSpec.describe ActsAsRecursiveTree::Options::Values do shared_examples 'single values' do subject(:value) { described_class.create(single_value) } it { is_expected.to be_a described_class::SingleValue } it 'apply_toes' do expect(value.apply_to(...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/model/location_spec.rb
Ruby
mit
86
main
1,118
# frozen_string_literal: true require 'spec_helper' RSpec.describe Location do before do @building = Building.create!(name: 'big house') 1.upto(5) do |index| floor = Floor.create!(name: "#{index}. Floor") @building.children << floor 1.upto(5) do |index_room| floor.children << Ro...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/model/relation_spec.rb
Ruby
mit
86
main
1,838
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'Relation' do include TreeMethods let(:root) { create_tree(4, stop_at: 2) } describe '#descendants' do context 'with simple relation' do let(:descendants) { root.descendants { |opts| opts.condition = Node.where(active: true) }.to_a }...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/model/node_spec.rb
Ruby
mit
86
main
2,199
# frozen_string_literal: true require 'spec_helper' RSpec.describe Node do include TreeMethods before do @root = create_tree(3) @child = @root.children.first end describe '#children' do it 'has 3 children' do expect(@root.children.count).to be(3) end it 'does not include root nod...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/db/database.rb
Ruby
mit
86
main
882
# frozen_string_literal: true require 'fileutils' database_folder = "#{File.dirname(__FILE__)}/../db" database_adapter = 'sqlite' # Logger setup ActiveRecord::Base.logger = nil ActiveRecord::Migration.verbose = false ActiveRecord::Base.configurations = YAML.safe_load_file("#{database_folder}/dat...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/db/schema.rb
Ruby
mit
86
main
691
# frozen_string_literal: true ActiveRecord::Schema.define(version: 0) do create_table :nodes do |t| t.integer :parent_id t.string :name t.boolean :active, default: true end add_foreign_key(:nodes, :nodes, column: :parent_id) create_table :node_infos do |t| t.belongs_to :node t.string :sta...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
spec/db/models.rb
Ruby
mit
86
main
658
# frozen_string_literal: true # Base test class class ApplicationRecord < ActiveRecord::Base self.abstract_class = true extend ActsAsRecursiveTree::ActsMacro end class Node < ApplicationRecord acts_as_tree has_one :node_info end class NodeInfo < ApplicationRecord belongs_to :node end class NodeWithPolymo...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree.rb
Ruby
mit
86
main
224
# frozen_string_literal: true require_relative 'acts_as_recursive_tree/railtie' if defined?(Rails) require 'zeitwerk' loader = Zeitwerk::Loader.for_gem loader.setup module ActsAsRecursiveTree # nothing special here end
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/scopes.rb
Ruby
mit
86
main
429
# frozen_string_literal: true module ActsAsRecursiveTree module Scopes extend ActiveSupport::Concern included do scope :roots, lambda { rel = where(_recursive_tree_config.parent_key => nil) if _recursive_tree_config.parent_type_column rel = rel.or( where.not(_recu...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/acts_macro.rb
Ruby
mit
86
main
792
# frozen_string_literal: true module ActsAsRecursiveTree module ActsMacro ## # Configuration options are: # # * <tt>foreign_key</tt> - specifies the column name to use for tracking # of the tree (default: +parent_id+) def recursive_tree(parent_key: :parent_id, parent_type_column: nil, depende...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/railtie.rb
Ruby
mit
86
main
274
# frozen_string_literal: true module ActsAsRecursiveTree class Railtie < Rails::Railtie initializer 'acts_as_recursive_tree.active_record_initializer' do ActiveRecord::Base.class_exec do extend ActsAsRecursiveTree::ActsMacro end end end end
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/config.rb
Ruby
mit
86
main
1,105
# frozen_string_literal: true module ActsAsRecursiveTree # # Stores the configuration of one Model class # class Config attr_reader :parent_key, :parent_type_column, :depth_column, :dependent def initialize(model_class:, parent_key:, parent_type_column:, depth_column: :recursive_depth, dependent: nil)...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/model.rb
Ruby
mit
86
main
3,483
# frozen_string_literal: true module ActsAsRecursiveTree module Model extend ActiveSupport::Concern ## # Returns list of ancestors, starting from parent until root. # # subchild1.ancestors # => [child1, root] # def ancestors(&) base_class.ancestors_of(self, &) end # Return...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/associations.rb
Ruby
mit
86
main
767
# frozen_string_literal: true require 'active_support/concern' module ActsAsRecursiveTree module Associations extend ActiveSupport::Concern included do belongs_to :parent, class_name: base_class.to_s, foreign_key: _recursive_tree_config.parent_key, i...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/preloaders/descendants.rb
Ruby
mit
86
main
1,140
# frozen_string_literal: true module ActsAsRecursiveTree module Preloaders # # Preloads all descendants records for a given node and sets the parent and child associations on each record # based on the preloaded data. After this, calling #parent or #children will not trigger a database query. # c...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/relation_builder.rb
Ruby
mit
86
main
4,540
# frozen_string_literal: true require 'securerandom' module ActsAsRecursiveTree module Builders # # Constructs the Arel necessary for recursion. # class RelationBuilder def self.build(klass, ids, exclude_ids: false, &block) new(klass, ids, exclude_ids:, &block).build end c...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/leaves.rb
Ruby
mit
86
main
621
# frozen_string_literal: true module ActsAsRecursiveTree module Builders class Leaves < Descendants def create_select_manger(column = nil) select_manager = super select_manager.where( travers_loc_table[primary_key].not_in( travers_loc_table.where( traver...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/ancestors.rb
Ruby
mit
86
main
322
# frozen_string_literal: true module ActsAsRecursiveTree module Builders class Ancestors < RelationBuilder self.traversal_strategy = ActsAsRecursiveTree::Builders::Strategies::Ancestor def get_query_options(&) opts = super opts.ensure_ordering! opts end end end en...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/descendants.rb
Ruby
mit
86
main
220
# frozen_string_literal: true module ActsAsRecursiveTree module Builders class Descendants < RelationBuilder self.traversal_strategy = ActsAsRecursiveTree::Builders::Strategies::Descendant end end end
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/strategies.rb
Ruby
mit
86
main
610
# frozen_string_literal: true module ActsAsRecursiveTree module Builders # # Strategy module for different strategies of how to build the resulting query. # module Strategies # # Returns a Strategy appropriate for query_opts # # @param query_opts [ActsAsRecursiveTree::Options:...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/strategies/subselect.rb
Ruby
mit
86
main
622
# frozen_string_literal: true module ActsAsRecursiveTree module Builders module Strategies # # Strategy for building a relation using an WHERE ID IN(...). # module Subselect # # Builds the relation. # # @param builder [ActsAsRecursiveTree::Builders::Relatio...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/strategies/ancestor.rb
Ruby
mit
86
main
407
# frozen_string_literal: true module ActsAsRecursiveTree module Builders module Strategies # # Strategy for building ancestors relation # module Ancestor # # Builds the relation # def self.build(builder) builder.travers_loc_table[builder.parent_ke...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/strategies/descendant.rb
Ruby
mit
86
main
411
# frozen_string_literal: true module ActsAsRecursiveTree module Builders module Strategies # # Strategy for building descendants relation # module Descendant # # Builds the relation # def self.build(builder) builder.base_table[builder.parent_key]....
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/builders/strategies/join.rb
Ruby
mit
86
main
1,000
# frozen_string_literal: true module ActsAsRecursiveTree module Builders module Strategies # # Build a relation using an INNER JOIN. # module Join # # Builds the relation. # # @param builder [ActsAsRecursiveTree::Builders::RelationBuilder] # @return...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/options/values.rb
Ruby
mit
86
main
1,990
# frozen_string_literal: true module ActsAsRecursiveTree module Options module Values class Base attr_reader :value, :config def initialize(value, config) @value = value @config = config end def prepared_value value end def a...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/options/query_options.rb
Ruby
mit
86
main
746
# frozen_string_literal: true module ActsAsRecursiveTree module Options class QueryOptions STRATEGIES = %i[subselect join].freeze def self.from options = new yield(options) if block_given? options end attr_accessor :condition attr_reader :ensure_ordering, :...
github
1and1/acts_as_recursive_tree
https://github.com/1and1/acts_as_recursive_tree
lib/acts_as_recursive_tree/options/depth_condition.rb
Ruby
mit
86
main
938
# frozen_string_literal: true module ActsAsRecursiveTree module Options class DepthCondition def ==(other) @value = Values.create(other) @operation = true end def !=(other) @value = Values.create(other) @operation = false end def <(other) ...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
Gemfile
Ruby
mit
86
master
305
source "https://rubygems.org" # Specify your gem's dependencies in faster_s3_url.gemspec gemspec gem "rake", "~> 12.0" gem "rspec", "~> 3.0" gem 'pry-byebug', "~> 3.9" # used by benchmark-ips in our perf/ profiling scripts. # https://github.com/evanphx/benchmark-ips#advanced-statistics gem 'kalibera'
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
faster_s3_url.gemspec
Ruby
mit
86
master
1,787
require_relative 'lib/faster_s3_url/version' Gem::Specification.new do |spec| spec.name = "faster_s3_url" spec.version = FasterS3Url::VERSION spec.authors = ["Jonathan Rochkind"] spec.email = ["jrochkind@sciencehistory.org"] spec.summary = %q{Generate public and presigned ...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
perf/presigned_bench.rb
Ruby
mit
86
master
3,200
# Run as eg: # # $ bundle exec ruby perf/presigned_bench.rb require 'benchmark/ips' require 'faster_s3_url' require 'aws-sdk-s3' require 'wt_s3_signer' access_key_id = "fakeExampleAccessKeyId" secret_access_key = "fakeExampleSecretAccessKey" bucket_name = "my-bucket" object_key = "some/directory/file.jpg" region =...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
perf/public_bench.rb
Ruby
mit
86
master
953
# Run as eg: # # $ bundle exec ruby perf/public_bench.rb require 'benchmark/ips' require 'faster_s3_url' require 'aws-sdk-s3' access_key_id = "fakeExampleAccessKeyId" secret_access_key = "fakeExampleSecretAccessKey" bucket_name = "my-bucket" object_key = "some/directory/file.jpg" region = "us-east-1" aws_client =...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
lib/faster_s3_url/builder_with_new_escape.rb
Ruby
mit
86
master
11,801
# frozen_string_literal: true require 'cgi' module FasterS3Url # Signing algorithm based on Amazon docs at https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html , # as well as some interactive code reading of Aws::Sigv4::Signer # https://github.com/aws/aws-sdk-ruby/blob/6114bc9692039a...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
lib/faster_s3_url/builder.rb
Ruby
mit
86
master
12,782
# frozen_string_literal: true require 'cgi' module FasterS3Url # Signing algorithm based on Amazon docs at https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html , # as well as some interactive code reading of Aws::Sigv4::Signer # https://github.com/aws/aws-sdk-ruby/blob/6114bc9692039a...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
lib/faster_s3_url/shrine/storage.rb
Ruby
mit
86
master
2,780
# frozen_string_literal: true gem "shrine", "~> 3.0" require 'shrine/storage/s3' module FasterS3Url module Shrine # More or less a drop-in replacement for Shrine::Storage::S3 , that uses FasterS3Url faster S3 URL generation. # https://shrinerb.com/docs/storage/s3 # # require 'faster_s3_url/stora...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
spec/shrine_storage_spec.rb
Ruby
mit
86
master
3,764
require 'spec_helper' require 'faster_s3_url/shrine/storage' # We're not gonna test everything and make sure it's good as a storage, we just # assume our light sub-class is doing what it's superclass is doing. Famous last words, # but it gets very complicated to test otherwise. # RSpec.describe FasterS3Url::Shrine::St...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
spec/builder_spec.rb
Ruby
mit
86
master
16,321
require 'spec_helper' require 'aws-sdk-s3' # For the most part we actually spec that results match what aws-sdk-s3 itself would generate! # RSpec.describe FasterS3Url::Builder do let(:access_key_id) { "fakeExampleAccessKeyId"} let(:secret_access_key) { "fakeExampleSecretAccessKey" } let(:session_token) { nil } ...
github
jrochkind/faster_s3_url
https://github.com/jrochkind/faster_s3_url
spec/spec_helper.rb
Ruby
mit
86
master
404
require "bundler/setup" require "faster_s3_url" require 'byebug' require 'timecop' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_mo...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
skinny_controllers.gemspec
Ruby
mit
86
master
1,696
# -*- encoding: utf-8 -*- # frozen_string_literal: true # allows bundler to use the gemspec for dependencies lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'skinny_controllers/version' Gem::Specification.new do |s| s.name = 'skinny_controllers' s...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
Gemfile
Ruby
mit
86
master
331
# frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in authorizable.gemspec gemspec version = ENV['RAILS_VERSION'] || '5.1' if version == 'master' git 'https://github.com/rails/rails.git' do gem 'rails' end else gem_version = "~> #{version}.0" gem 'rails', gem_v...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers.rb
Ruby
mit
86
master
2,886
# frozen_string_literal: true # required gems require 'active_support' require 'active_support/core_ext/class' require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/try' require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/module/delegation' # files for...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/logging.rb
Ruby
mit
86
master
641
# frozen_string_literal: true module SkinnyControllers module Logging extend ActiveSupport::Concern included do self.logger = Logger.new end class Logger attr_accessor :_logger attr_accessor :_tag def initialize @_logger = ActiveSupport::TaggedLogging.new(ActiveSuppor...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/default_verbs.rb
Ruby
mit
86
master
293
# frozen_string_literal: true module SkinnyControllers module DefaultVerbs # show Read = 'Read'.freeze # index ReadAll = 'ReadAll'.freeze # create Create = 'Create'.freeze # destroy Delete = 'Delete'.freeze # update Update = 'Update'.freeze end end
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup.rb
Ruby
mit
86
master
4,434
# frozen_string_literal: true module SkinnyControllers # This class provides a way to determine all names / classes of operations # and policies based on he given information. # # The class methods show what is required for each scenario class Lookup include EnsureExistence include Policy class <...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/diet.rb
Ruby
mit
86
master
3,381
# frozen_string_literal: true module SkinnyControllers module Diet extend ActiveSupport::Concern ALLOWED_OPTIONS = [ :model_class, :parent_class, :asociation_name, :model_params_key ].freeze included do class << self attr_accessor :options def skinny_controll...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup/ensure_existence.rb
Ruby
mit
86
master
3,927
module SkinnyControllers class Lookup # NOTE: This is a lot of hackery. # Please Explicitly Define things if you are able module EnsureExistence module_function # @return [Module] namespace def ensure_namespace!(namespace) klass = namespace_lookup(namespace) klass ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup/namespace.rb
Ruby
mit
86
master
1,013
# frozen_string_literal: true module SkinnyControllers class Lookup module Namespace module_function # iterate through the namespaces until one doesn't exist, and create the rest def create_namespace(desired_namespace) if klass = desired_namespace.safe_constantize return klass...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup/policy.rb
Ruby
mit
86
master
1,639
# frozen_string_literal: true module SkinnyControllers class Lookup module Policy module_function # @param [String] name the name of the model # @return [Class] the policy class def class_from_model(name) policy_class_name = class_name_from_model(name) klass = policy_class...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup/model.rb
Ruby
mit
86
master
999
# frozen_string_literal: true module SkinnyControllers class Lookup module Model module_function # @example 'ObjectOperations::Verb' => Object # # @return [Class] class based on the operation def class_from_operation(operation_name) # "Namespace::Model" => "Model" mo...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/lookup/operation.rb
Ruby
mit
86
master
2,398
# frozen_string_literal: true module SkinnyControllers class Lookup module Operation module_function # @example ObjectOperations::Verb # # @param [String] model_name name of the model # @param [String] verb the verb/action for the operation # @return [Class] the operation base...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/policy/allow_all.rb
Ruby
mit
86
master
241
# frozen_string_literal: true module SkinnyControllers module Policy class AllowAll < Base def default? true end def read? true end def read_all? true end end end end
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/policy/deny_all.rb
Ruby
mit
86
master
243
# frozen_string_literal: true module SkinnyControllers module Policy class DenyAll < Base def default? false end def read? false end def read_all? false end end end end
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/policy/base.rb
Ruby
mit
86
master
2,975
# frozen_string_literal: true module SkinnyControllers module Policy class Base attr_accessor :user, :object, :authorized_via_parent # @param [User] user the being to check if they have access to `object` # @param [ActiveRecord::Base] object the object that we are wanting to check # th...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/operation/base.rb
Ruby
mit
86
master
3,374
# frozen_string_literal: true module SkinnyControllers module Operation # # An example Operation may looy like # # module EventOperations # class Read < SkinnyControllers::Operation::Base # def run # model if allowed? # end # end # end # # TODO: make t...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/operation/default.rb
Ruby
mit
86
master
916
# frozen_string_literal: true module SkinnyControllers module Operation class Default < Base def run # Note that for explicitly defined operations, # There should be a different operation for each # action. # # e.g.: # - EventOperations::Create # - E...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/skinny_controllers/operation/model_helpers.rb
Ruby
mit
86
master
3,303
# frozen_string_literal: true module SkinnyControllers module Operation module ModelHelpers def model # TODO: not sure if multiple ids is a good idea here # if we don't have a(ny) id(s), get all of them @model ||= find_model end # hopefully this method is only ever calle...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/generators/policy/policy_generator.rb
Ruby
mit
86
master
469
# frozen_string_literal: true class PolicyGenerator < Rails::Generators::NamedBase # gives us file_name source_root File.expand_path('../templates', __FILE__) def generate_layout template 'policy.rb.erb', File.join('app/policies', class_path, "#{file_name}_policy.rb") end def policy_name operation_n...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/generators/skinny_controller/skinny_controller_generator.rb
Ruby
mit
86
master
709
# frozen_string_literal: true class SkinnyControllerGenerator < Rails::Generators::NamedBase # gives us file_name source_root File.expand_path('../templates', __FILE__) def generate_layout template 'skinny_controller.rb.erb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") end ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
lib/generators/operation/operation_generator.rb
Ruby
mit
86
master
426
# frozen_string_literal: true class OperationGenerator < Rails::Generators::NamedBase # gives us file_name source_root File.expand_path('../templates', __FILE__) def generate_layout template 'operation.rb.erb', File.join('app/operations', class_path, "#{file_name}_operations.rb") end def operation_name ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/rails_helper.rb
Ruby
mit
86
master
542
# frozen_string_literal: true require 'rails/all' require 'factory_girl' require 'factory_girl_rails' require 'rspec/rails' require 'support/rails_app/config/environment' ActiveRecord::Migration.maintain_test_schema! # set up db # be sure to update the schema if required by doing # - cd spec/rails_app # - rake db:m...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/spec_helper.rb
Ruby
mit
86
master
1,236
# frozen_string_literal: true require 'rubygems' require 'bundler/setup' require 'pry-byebug' # binding.pry to debug! require 'awesome_print' # Coverage require 'simplecov' SimpleCov.start do add_filter '/spec/' end # This Gem require 'skinny_controllers' $LOAD_PATH.unshift Dir[File.dirname(__FILE__) + '/support/...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/lookup_spec.rb
Ruby
mit
86
master
2,931
# frozen_string_literal: true require 'rails_helper' describe SkinnyControllers::Lookup do let(:klass) { SkinnyControllers::Lookup } context 'the operation namespace matches the controller namespace' do # app/controllers/api/v2/posts_controller.rb # app/operations/api/v2/post_operations.rb context 't...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/diet_spec.rb
Ruby
mit
86
master
2,692
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Diet do # # RSpec.describe FakeObjectsController, :type => :controller do # controller do # include # end # end class FakeObjectsController < FakeController include SkinnyControllers::Diet end class ExamplesC...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/policy/base_spec.rb
Ruby
mit
86
master
2,130
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Policy::Base do let(:klass) { SkinnyControllers::Policy::Base } context :instantiation do it 'sets accessors' do b = klass.new(1, 2, authorized_via_parent: true) expect(b.user).to eq 1 expect(b.object).to eq 2 ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/policy/_all_spec.rb
Ruby
mit
86
master
868
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Policy::DenyAll do let(:klass) { SkinnyControllers::Policy::DenyAll } let(:policy) { klass.new(nil, nil) } it { expect(policy.read?).to eq false } it { expect(policy.read_all?).to eq false } it { expect(policy.update?).to eq fal...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/lookup/namespace_spec.rb
Ruby
mit
86
master
850
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Lookup::Namespace do let(:klass) { SkinnyControllers::Lookup::Namespace } context :create_namespace do after(:each) do # just in case of race conditions if defined? Hi # this is a scary command o.o Obje...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/lookup/model_lookup_spec.rb
Ruby
mit
86
master
634
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Lookup::Model do let(:klass) { SkinnyControllers::Lookup::Model } context :class_from_operation_name do end context :name_from_operation do it 'handles regular models' do operation_name = 'ItemOperations::Default' ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/lookup/policy_lookup_spec.rb
Ruby
mit
86
master
783
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Lookup::Policy do let(:klass) { SkinnyControllers::Lookup::Policy } context :class_from_model do it 'returns the policy class' do result = klass.class_from_model(Example.name) expect(result).to eq ExamplePolicy end...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/lookup/operation_lookup_spec.rb
Ruby
mit
86
master
2,166
# frozen_string_literal: true require 'spec_helper' describe SkinnyControllers::Lookup::Operation do let(:klass) { SkinnyControllers::Lookup::Operation } context :model_name_to_operation_namespace do end context :operation_of do end context :from_controller do end context :default_operation_class_fo...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/unit/operation/operation_spec.rb
Ruby
mit
86
master
2,048
# frozen_string_literal: true require 'spec_helper' describe ExampleOperations::Read do let(:klass) { ExampleOperations::Read } describe 'static shorthand access' do it 'creates and runs the opreation' do skip 'No idea why self.new in a class method returns nil' expect(ExamplePolicy).to receive(:a...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/no_operations_controller_spec.rb
Ruby
mit
86
master
800
# frozen_string_literal: true require 'rails_helper' describe NoOperationsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'show' do it 'gets the model - because the current_user is passed through the anonymous operation to the explicit policy' ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/custom_model_controller_spec.rb
Ruby
mit
86
master
388
# frozen_string_literal: true require 'rails_helper' describe EventSummariesController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end it 'renders the event as there is no event summary' do event = create(:event) get :show, params: { id: event.id } json = JSON.p...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/namespaced_controller_spec.rb
Ruby
mit
86
master
448
# frozen_string_literal: true require 'rails_helper' describe ItemsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'create' do it 'creates an event' do expect do post :create, params: { item: { name: 'created' } } end.to change(Supe...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/single_resource_controller_spec.rb
Ruby
mit
86
master
876
# frozen_string_literal: true require 'rails_helper' describe EventsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end it 'returns an empty set of events' do get :index expect(response.body).to eq '[]' end context 'events exist' do let(:event1) { cr...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/namespaced_relationship_controller_spec.rb
Ruby
mit
86
master
1,029
# frozen_string_literal: true require 'rails_helper' describe OtherItemsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'index' do before(:each) do @s = s = SuperItem.new(name: 'super') s.save i1 = SuperItem::OtherItem.new(name: 'sub1...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/default_all_controller_spec.rb
Ruby
mit
86
master
432
# frozen_string_literal: true require 'rails_helper' describe UsersController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'show' do it 'does not render the model (policy is DenyAll)' do user = create(:user) get :show, params: { id: user.id } ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/json_api_spec.rb
Ruby
mit
86
master
1,029
# frozen_string_literal: true require 'rails_helper' describe JsonApiEventsController, type: :controller do context 'JSON API Support' do context 'create / POST' do it 'creates a resource' do json_api = { 'data' => { 'attributes' => { 'name' => 'new_name' ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/scoped_resource_controller_spec.rb
Ruby
mit
86
master
1,942
# frozen_string_literal: true require 'rails_helper' describe DiscountsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' @event = create(:event) end it 'calls a non-crud action' do discount = create(:discount, event: @event) expect_any_instance_of(DiscountOp...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/load_path_spec.rb
Ruby
mit
86
master
491
# frozen_string_literal: true require 'rails_helper' describe 'definitions of operations and policies' do # HACK: to get the environment loaded describe EventsController, type: :controller do before(:each) do get :load_hack end it 'loads operations' do is_defined = defined? EventOperations...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/json_api_events_controller_spec.rb
Ruby
mit
86
master
340
# frozen_string_literal: true require 'rails_helper' describe JsonApiEventsController, type: :controller do context 'destroy' do it 'destroys a record, ignoring event_params' do event = create(:event) expect do delete :destroy, params: { id: event.id } end.to change(Event, :count).by(-1...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/crud_controller_spec.rb
Ruby
mit
86
master
1,509
# frozen_string_literal: true require 'rails_helper' describe UsersController, type: :controller do context 'destroy with explicit destroy operation' do it 'is allowed' do user = create(:user) allow(controller).to receive(:current_user) { user } expect do delete :destroy, params: { id:...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/namespaced_operation_and_controller_spec.rb
Ruby
mit
86
master
296
require 'rails_helper' describe Api::V2::PostsController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'create' do it 'uses the operation' do post :create expect(response.body).to eq 'namespaced operation' end end end
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/strong_parameters_spec.rb
Ruby
mit
86
master
640
# frozen_string_literal: true require 'rails_helper' describe StrongParametersController, type: :controller do context '{model}_params' do it 'calls the model params' do expect(controller).to receive(:event_params).and_call_original post :create, params: { event: { name: 'created' } } end end ...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/requires_parent_controller_spec.rb
Ruby
mit
86
master
2,296
# frozen_string_literal: true require 'rails_helper' describe RequiresParentController, type: :controller do before(:each) do load 'support/rails_app/db/schema.rb' end context 'index' do it 'is scoped to a parent relationship' do event = create(:event) create(:discount) discount = crea...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/integration/rails/operations/model_helpers_spec.rb
Ruby
mit
86
master
1,559
# frozen_string_literal: true require 'rails_helper' describe EventOperations do describe :find_model do it 'detects a parent.child.find relationship' do event = create(:event) create(:discount, event: event) discount = create(:discount, event: event) # note that parameters in the contro...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/support/fake_controller.rb
Ruby
mit
86
master
377
# frozen_string_literal: true # 2cool4 ActionController::Base class FakeController # http://www.rubydoc.info/docs/rails/2.3.8/ActionController%2FBase%3Aaction_name def action_name 'index' end def current_user @current_user ||= TestUser.new end # kinda: # http://api.rubyonrails.org/classes/Action...
github
NullVoxPopuli/skinny_controllers
https://github.com/NullVoxPopuli/skinny_controllers
spec/support/rails_app/factories.rb
Ruby
mit
86
master
267
# frozen_string_literal: true FactoryGirl.define do factory :user do end factory :event do name 'Test Event' association :user, factory: :user end factory :discount do name 'Some Discount' event end factory :no_operation do end end