Skip to content

Commit

Permalink
Merge pull request #2 from redbooth/fix-dependencies
Browse files Browse the repository at this point in the history
Be less restrictive on the rubocop  version required.
  • Loading branch information
magec authored Oct 10, 2016
2 parents 57fafd6 + 5acd998 commit fd952a5
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/spec/reports/
/tmp/
*~
gemfiles/vendor
gemfiles/*.lock
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ language: ruby
rvm:
- 2.3.0
before_install: gem install bundler -v 1.11.2
gemfile:
- gemfiles/rubocop_0.41.gemfile
- gemfiles/rubocop_0.42.gemfile
- gemfiles/rubocop_0.43.gemfile
- gemfiles/latest_rubocop.gemfile
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appraise 'rubocop-0.41' do
gem 'rubocop', '~> 0.41.0'
end

appraise 'rubocop-0.42' do
gem 'rubocop', '~> 0.42.0'
end

appraise 'rubocop-0.43' do
gem 'rubocop', '~> 0.43.0'
end

appraise 'latest-rubocop' do
gem 'rubocop'
end
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# RuboCop Migrations

Rails migrations analysis as a extension of [RuboCop](https://github.com/bbatsov/rubocop). Heavily inspired by [`rubocop-cask`](https://github.com/caskroom/rubocop-cask) which in turn is inspired by [`rubocop-rspec`](https://github.com/nevir/rubocop-rspec).
Rails migrations analysis as a extension
of [RuboCop](https://github.com/bbatsov/rubocop). Heavily inspired
by [`rubocop-cask`](https://github.com/caskroom/rubocop-cask) which in turn is
inspired by [`rubocop-rspec`](https://github.com/nevir/rubocop-rspec).

## Installation

Just install the `rubocop-migrations` gem

```bash
```shell
gem install rubocop-migrations
```

Expand All @@ -19,7 +22,8 @@ gem 'rubocop-migrations'

## Usage

You need to tell RuboCop to load the Migrations extension. There are three ways to do this:
You need to tell RuboCop to load the Migrations extension. There are three ways
to do this:

### RuboCop configuration file

Expand All @@ -29,19 +33,23 @@ Put this into your `.rubocop.yml`:
require: rubocop/migrations
```
Now you can run `rubocop` and it will automatically load the RuboCop Migrations cops together with the standard cops.
Now you can run `rubocop` and it will automatically load the RuboCop Migrations
cops together with the standard cops.

### Command line

```bash
```shell
rubocop --require rubocop/migrations
```

## The Cop

All cops are located under [`lib/rubocop/cop/migrations`](lib/rubocop/cop/migrations), and contain examples/documentation.
All cops are located
under [`lib/rubocop/cop/migrations`](lib/rubocop/cop/migrations), and contain
examples/documentation.

In your `.rubocop.yml`, you may treat the Cask cops just like any other cop. For example:
In your `.rubocop.yml`, you may treat the Cask cops just like any other cop. For
example:

```yaml
Migrations/RemoveIndex:
Expand All @@ -56,13 +64,25 @@ Migrations/RemoveIndex:
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

For running the spec files, this project depends on RuboCop's spec helpers. This means that in order to run the specs locally, you need a (shallow) clone of the RuboCop repository:
### Running the tests

```bash
git submodule update --init --depth 1 vendor/rubocop
We use Appraisals in order to run the tests with different rubocop versions to
ensure compatibility.

To run the specs with all supported rubocop versions first install the required
dependencies with:

```shell
bundle exec appraisals install
```

Then run the specs by just running `rake` it will run specs with all the
versions.

For more info just check the appraisals documentation
https://github.com/thoughtbot/appraisal

## License

`rubocop-migrations` is MIT licensed. [See the accompanying file](MIT-LICENSE.md) for
the full text.
`rubocop-migrations` is MIT
licensed. [See the accompanying file](MIT-LICENSE.md) for the full text.
15 changes: 11 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'rubygems'
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'appraisal'

RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:test)

task :default => :spec
if !ENV['APPRAISAL_INITIALIZED'] && !ENV['TRAVIS']
task default: :appraisal
else
task default: :test
end
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_DISABLE_SHARED_GEMS: "true"
7 changes: 7 additions & 0 deletions gemfiles/latest_rubocop.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rubocop_0.41.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", "~> 0.41.0"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rubocop_0.42.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", "~> 0.42.0"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rubocop_0.43.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rubocop", "~> 0.43.0"

gemspec :path => "../"
5 changes: 3 additions & 2 deletions rubocop-migrations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_runtime_dependency 'rubocop', '~> 0.41.0'
spec.add_runtime_dependency 'rubocop', '~> 0.41'

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '3.5.0'
spec.add_development_dependency 'rspec', '~> 3.5'
spec.add_development_dependency 'appraisal'
end

0 comments on commit fd952a5

Please sign in to comment.