Skip to content

Commit

Permalink
refactor: rename gem by rubygems requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
loqimean committed Jul 14, 2023
1 parent 1f3abe9 commit 1b288cd
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 176 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
sudo systemctl start mysql.service
- name: Setup databases
run: |
mysql --user=root --password=root --host=127.0.0.1 -e 'create database active_record_random_test collate utf8_general_ci;';
mysql --user=root --password=root --host=127.0.0.1 -e 'use active_record_random_test;show variables like "%character%";show variables like "%collation%";';
mysql --user=root --password=root --host=127.0.0.1 -e 'create database random_rails_test collate utf8_general_ci;';
mysql --user=root --password=root --host=127.0.0.1 -e 'use random_rails_test;show variables like "%character%";show variables like "%collation%";';
- name: Run tests
run: bundle exec rspec

Expand Down Expand Up @@ -105,6 +105,6 @@ jobs:
bundler-cache: true
- name: Setup databases
run: |
psql -h localhost -p 5432 -W postgres -c 'create database active_record_random_test;' -U postgres;
psql -h localhost -p 5432 -W postgres -c 'create database random_rails_test;' -U postgres;
- name: Run tests
run: bundle exec rspec
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

# Specify your gem's dependencies in active_record_random.gemspec
# Specify your gem's dependencies in random-rails.gemspec
gemspec

gem "rake", "~> 13.0"
128 changes: 0 additions & 128 deletions Gemfile.lock

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ The most perfomant way to get random records from ActiveRecord. In fact, it's th
Install the gem and add to the application's Gemfile by executing:

```bash
bundle add active_record_random
bundle add random-rails
```

If bundler is not being used to manage dependencies, install the gem by executing:

```bash
gem install active_record_random
gem install random-rails
```

## Usage
Expand Down Expand Up @@ -47,12 +47,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/the-rubies-way/active_record_random. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/the-rubies-way/active_record_random/blob/master/CODE_OF_CONDUCT.md).
Bug reports and pull requests are welcome on GitHub at https://github.com/the-rubies-way/random-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/the-rubies-way/random-rails/blob/master/CODE_OF_CONDUCT.md).

## 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 ActiveRecord::Random project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/the-rubies-way/active_record_random/blob/master/CODE_OF_CONDUCT.md).
Everyone interacting in the ActiveRecord::Random project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/the-rubies-way/random-rails/blob/master/CODE_OF_CONDUCT.md).
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "bundler/setup"
require "active_record"
require "active_support"
require "active_record_random"
require "random-rails"

# 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 bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -vx
# PostgreSQL
if [ -x "$(command -v psql)" ]; then
echo "PostgreSQL is installed"
psql -h localhost -p 5432 -W postgres -c 'create database active_record_random_test;' -U postgres;
psql -h localhost -p 5432 -W postgres -c 'create database random_rails_test;' -U postgres;
else
echo "PostgreSQL is not installed"
# check it is mac or linux
Expand All @@ -21,15 +21,15 @@ else

# create psql user
sudo -u postgres createuser -s $(whoami)
psql -h localhost -p 5432 -W postgres -c 'create database active_record_random_test;' -U $(whoami);
psql -h localhost -p 5432 -W postgres -c 'create database random_rails_test;' -U $(whoami);

exit 1
fi

# MySQL 2
if [ -x "$(command -v mysql)" ]; then
echo "MySQL is installed"
mysql -h localhost -P 3306 -u root -e 'create database active_record_random_test;'
mysql -h localhost -P 3306 -u root -e 'create database random_rails_test;'
else
echo "MySQL is not installed"
# check it is mac or linux
Expand All @@ -40,7 +40,7 @@ else
fi

# create mysql user
mysql -h localhost -P 3306 -u root -e 'create database active_record_random_test;'
mysql -h localhost -P 3306 -u root -e 'create database random_rails_test;'

exit 1
fi
Expand Down
8 changes: 0 additions & 8 deletions lib/active_record_random.rb

This file was deleted.

8 changes: 0 additions & 8 deletions lib/active_record_random/active_record.rb

This file was deleted.

8 changes: 8 additions & 0 deletions lib/random-rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

require "random-rails/version"
require "random-rails/active_record"

module RandomRails
class Error < StandardError; end
end
8 changes: 8 additions & 0 deletions lib/random-rails/active_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "active_support"
require "active_support/core_ext"

require "random-rails/adapters/active_record/base"

ActiveSupport.on_load(:active_record) do
extend RandomRails::Adapters::ActiveRecord::Base
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ActiveRecordRandom
module RandomRails
module Adapters
module ActiveRecord
module Base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ActiveRecordRandom
module RandomRails
VERSION = "0.1.0"
end
8 changes: 4 additions & 4 deletions active_record_random.gemspec → random-rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

$:.push File.expand_path("../lib", __FILE__)
require "active_record_random/version"
require "random-rails/version"

Gem::Specification.new do |spec|
spec.name = "active_record_random"
spec.version = ActiveRecordRandom::VERSION
spec.name = "random-rails"
spec.version = RandomRails::VERSION
spec.authors = ["loqimean"]
spec.email = ["[email protected]"]

spec.summary = "Awesome gem to get random records from database."
spec.description = "The easiest way to get random records from database with best performance that you ever seen."
spec.homepage = "https://github.com/the-rubies-way/active_record_random"
spec.homepage = "https://github.com/the-rubies-way/random-rails"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ActiveRecordRandom
module RandomRails
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
end
7 changes: 0 additions & 7 deletions spec/lib/active_record_random_spec.rb

This file was deleted.

7 changes: 7 additions & 0 deletions spec/lib/random-rails_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

RSpec.describe RandomRails do
it "has a version number" do
expect(RandomRails::VERSION).not_to be nil
end
end
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe ActiveRecordRandom::Adapters::ActiveRecord::Base do
RSpec.describe RandomRails::Adapters::ActiveRecord::Base do
describe "#random" do
it { expect(Person).to respond_to(:random) }
it { expect(Person.random).to be_a(ActiveRecord::Relation) }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
SimpleCov.minimum_coverage 100
SimpleCov.add_filter "/spec/"

require "active_record_random"
require "random-rails"

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }

Expand Down
6 changes: 3 additions & 3 deletions spec/support/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# To test with MySQL: `DB=mysql bundle exec rake spec`
ActiveRecord::Base.establish_connection(
adapter: 'mysql2',
database: 'active_record_random_test',
database: 'random_rails_test',
username: ENV.fetch("MYSQL_USERNAME") { "root" },
password: ENV.fetch("MYSQL_PASSWORD") { "" },
encoding: 'utf8'
Expand All @@ -14,7 +14,7 @@
# To test with PostgreSQL: `DB=postgresql bundle exec rake spec`
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
database: "active_record_random_test",
database: "random_rails_test",
username: ENV.fetch("DATABASE_USERNAME") { "postgres" },
password: ENV.fetch("DATABASE_PASSWORD") { "" },
host: ENV.fetch("DATABASE_HOST") { "localhost" },
Expand All @@ -30,7 +30,7 @@

# This is just a test app with no sensitive data. In general, end users should
# explicitly authorize each model, but this shows a way to configure the
# unrestricted default behavior of an active_record_random gem.
# unrestricted default behavior of an random-rails gem.
#
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
Expand Down

0 comments on commit 1b288cd

Please sign in to comment.