Skip to content

Commit

Permalink
renamed gem from action_filter to filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
dubadub committed Jun 2, 2019
1 parent d4be73c commit d19ccad
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
action_filter (0.1.0)
filtered (0.1.0)

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

DEPENDENCIES
action_filter!
filtered!
appraisal (~> 2.2)
bundler (~> 2.0)
rake (~> 10.0)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand All @@ -18,7 +18,7 @@ And then execute:

Or install it yourself as:

$ gem install action_filter
$ gem install filtered

## Usage

Expand All @@ -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).
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 4 additions & 4 deletions action_filter.gemspec → filtered.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ["[email protected]"]

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.
Expand Down
7 changes: 0 additions & 7 deletions lib/action_filter.rb

This file was deleted.

7 changes: 7 additions & 0 deletions lib/filtered.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "filtered/version"
require "filtered/field_definition"
require "filtered/base"

module Filtered
class Error < StandardError; end
end
2 changes: 1 addition & 1 deletion lib/action_filter/base.rb → lib/filtered/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ActionFilter
module Filtered
class Base

def self.inherited(base)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ActionFilter
module Filtered
class FieldDefinition

attr_writer :query_update_proc, :accept_if
Expand Down
2 changes: 1 addition & 1 deletion lib/action_filter/version.rb → lib/filtered/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActionFilter
module Filtered
VERSION = "0.1.0"
end
2 changes: 1 addition & 1 deletion spec/active_record_intergration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
30 changes: 15 additions & 15 deletions spec/action_filter_spec.rb → spec/filtered_spec.rb
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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?
Expand All @@ -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?
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "bundler/setup"
require "action_filter"
require "filtered"

require "rubygems"
require "bundler/setup"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions spec/support/sql_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.