Skip to content
Permalink
Browse files

renamed gem from action_filter to filtered

  • Loading branch information...
dubadub committed Jun 2, 2019
1 parent d4be73c commit d19ccad72c97dcdd58aa6ec3922dc5d117416497
@@ -1,4 +1,4 @@
source "https://rubygems.org"

# Specify your gem's dependencies in action_filter.gemspec
# Specify your gem's dependencies in filtered.gemspec
gemspec
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
action_filter (0.1.0)
filtered (0.1.0)

GEM
remote: https://rubygems.org/
@@ -31,7 +31,7 @@ PLATFORMS
ruby

DEPENDENCIES
action_filter!
filtered!
appraisal (~> 2.2)
bundler (~> 2.0)
rake (~> 10.0)
@@ -1,6 +1,6 @@
# ActionFilter
# Filtered

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/action_filter`. To experiment with that code, run `bin/console` for an interactive prompt.
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/filtered`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
Add this line to your application's Gemfile:

```ruby
gem 'action_filter'
gem 'filtered'
```

And then execute:
@@ -18,7 +18,7 @@ And then execute:

Or install it yourself as:

$ gem install action_filter
$ gem install filtered

## Usage

@@ -32,12 +32,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/action_filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/filtered. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the ActionFilter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/action_filter/blob/master/CODE_OF_CONDUCT.md).
Everyone interacting in the Filtered project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/filtered/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "action_filter"
require "filtered"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
@@ -1,16 +1,16 @@

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "action_filter/version"
require "filtered/version"

Gem::Specification.new do |spec|
spec.name = "action_filter"
spec.version = ActionFilter::VERSION
spec.name = "filtered"
spec.version = Filtered::VERSION
spec.authors = ["Alexey Dubovskoy"]
spec.email = ["dubovskoy.a@gmail.com"]

spec.summary = %q{Filters ActiveRecord queries in a contoller}
spec.homepage = "https://github.com/dubadub/active_filter"
spec.homepage = "https://github.com/dubadub/filtered"
spec.license = "MIT"

# Specify which files should be added to the gem when it is released.

This file was deleted.

@@ -0,0 +1,7 @@
require "filtered/version"
require "filtered/field_definition"
require "filtered/base"

module Filtered
class Error < StandardError; end
end
@@ -1,4 +1,4 @@
module ActionFilter
module Filtered
class Base

def self.inherited(base)
@@ -1,4 +1,4 @@
module ActionFilter
module Filtered
class FieldDefinition

attr_writer :query_update_proc, :accept_if
@@ -1,3 +1,3 @@
module ActionFilter
module Filtered
VERSION = "0.1.0"
end
@@ -22,7 +22,7 @@ class Child < ActiveRecord::Base
end

let(:filter_class) do
Class.new(ActionFilter::Base) do
Class.new(Filtered::Base) do
field :status

field :has_children, if: ->(value) { !!value } do |value|
@@ -1,15 +1,15 @@
RSpec.describe ActionFilter do
RSpec.describe Filtered do
it "has a version number" do
expect(ActionFilter::VERSION).not_to be nil
expect(Filtered::VERSION).not_to be nil
end

describe "DSL" do
it "doesn't clash with other class" do
class FilterOne < ActionFilter::Base
class FilterOne < Filtered::Base
field :status
end

class FilterTwo < ActionFilter::Base
class FilterTwo < Filtered::Base
field :reason
end

@@ -21,7 +21,7 @@ class FilterTwo < ActionFilter::Base
end

it "blows up when setting field which is not defined" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status
end

@@ -31,7 +31,7 @@ class MyFilter < ActionFilter::Base
describe "field" do
context "without parameters" do
it "works with value present" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status
end

@@ -41,7 +41,7 @@ class MyFilter < ActionFilter::Base
end

it "works when no value present" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status
end

@@ -53,7 +53,7 @@ class MyFilter < ActionFilter::Base

context "with block parameter" do
it "works" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status do |value|
-> { where(status: value) }
end
@@ -65,7 +65,7 @@ class MyFilter < ActionFilter::Base
end

it "gives access to filter instance" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status do |value, filter|
-> { where(status: filter.prefixed(value)) }
end
@@ -82,7 +82,7 @@ def prefixed(value)

xit "raises an error if field definition doesn't return lambda" do
expect {
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status do |value|
"hello"
end
@@ -95,7 +95,7 @@ class MyFilter < ActionFilter::Base
context "field options" do
describe "if: ..." do
xit "supports 'if: :method_name'" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status, if: :use_field?

def use_field?
@@ -109,7 +109,7 @@ def use_field?
end

xit "supports 'unless: :method_name'" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status, unless: :skip_field?

def skip_field?
@@ -123,7 +123,7 @@ def skip_field?
end

it "supports 'if: ->() {...}'" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status, if: ->(value) { false }
end

@@ -133,7 +133,7 @@ class MyFilter < ActionFilter::Base
end

it "supports 'if: ->() {...}'" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status, if: ->(value) { true }
end

@@ -146,7 +146,7 @@ class MyFilter < ActionFilter::Base

describe "allow_blank: ..." do
xit "supports 'allow_blank: true'" do
class MyFilter < ActionFilter::Base
class MyFilter < Filtered::Base
field :status, allow_blank: true
end

@@ -1,5 +1,5 @@
require "bundler/setup"
require "action_filter"
require "filtered"

require "rubygems"
require "bundler/setup"
@@ -10,6 +10,7 @@
$LOAD_PATH.unshift File.expand_path("support", __dir__)
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }


RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
@@ -29,11 +29,11 @@ def connect_postgres
ActiveRecord::Base.establish_connection(adapter: "postgresql", host: "localhost",
database: "postgres", schema_search_path: "public")

ActiveRecord::Base.connection.drop_database("action_filter_postgresql_spec")
ActiveRecord::Base.connection.create_database("action_filter_postgresql_spec",
ActiveRecord::Base.connection.drop_database("filtered_postgresql_spec")
ActiveRecord::Base.connection.create_database("filtered_postgresql_spec",
encoding: "utf-8", adapter: "postgresql")

ActiveRecord::Base.establish_connection(adapter: "postgresql", host: "localhost",
database: "action_filter_postgresql_spec")
database: "filtered_postgresql_spec")
end
end

0 comments on commit d19ccad

Please sign in to comment.
You can’t perform that action at this time.