latest_migration 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +25 -0
- data/lib/latest_migration/base.rb +45 -0
- data/lib/latest_migration/errors.rb +21 -0
- data/lib/latest_migration/railtie.rb +12 -0
- data/lib/latest_migration/version.rb +3 -0
- data/lib/latest_migration.rb +5 -0
- data/lib/tasks/latest_migration_tasks.rake +11 -0
- metadata +110 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 792e6fd9e2242e833f766eef2f4a90ee606033b8
|
|
4
|
+
data.tar.gz: 640e3f31d966dc8a7f9d4d8da147a9675056b825
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 52b685812e7870c45e000dc5812071aa2280f85e3682a1448268029d23203599ba1bd62b50aadfa7c63c72a23617f4dc512b1462c9fb9027aac5cd33593a69e1
|
|
7
|
+
data.tar.gz: c36693c2207f6d575d0de392ee13f0af93928ebe5bd3d82c9b7c3d0582ba6ab156156d227ad458da1ee6600d4d5dce29672ed83b23694950d8b9b791a82a1e34
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 Arkadiusz Fal
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[<img src="https://travis-ci.org/arekf/latest_migration.svg?branch=master" alt="Build Status" />](https://travis-ci.org/arekf/latest_migration) [<img src="https://codeclimate.com/github/arekf/latest_migration/badges/gpa.svg" />](https://codeclimate.com/github/arekf/latest_migration) [<img src="https://codeclimate.com/github/arekf/latest_migration/badges/coverage.svg" />](https://codeclimate.com/github/arekf/latest_migration) [<img src="https://badge.fury.io/rb/latest_migration.svg" alt="Gem Version" />](http://badge.fury.io/rb/latest_migration)
|
|
2
|
+
|
|
3
|
+
# latest_migration
|
|
4
|
+
|
|
5
|
+
`latest_migration` is a Ruby on Rails gem that allows you to open your latest
|
|
6
|
+
migration file in text editor. It saves the time of selecting, copying
|
|
7
|
+
and opening the file in your editor.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
* Add `latest_migration` to your Gemfile:
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'latest_migration', group: development
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
* Install with: bundle install
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
When installed, you have available two new Rake tasks:
|
|
20
|
+
```
|
|
21
|
+
rake latest_migration:open
|
|
22
|
+
rake latest_migration:path
|
|
23
|
+
```
|
|
24
|
+
The first one opens the latest migration in the text editor.
|
|
25
|
+
|
|
26
|
+
By default it uses `subl` command to open the file. You can override this with initializer:
|
|
27
|
+
```ruby
|
|
28
|
+
# config/initializers/latest_migration.rb
|
|
29
|
+
LatestMigration::Base.editor = :mine
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
You can use pass any command name you wish (like `:mine`, `:nano` etc.).
|
|
33
|
+
|
|
34
|
+
The second command just prints the filename of latest migration to standard output, like:
|
|
35
|
+
```
|
|
36
|
+
/Users/Arek/Workspace/myapp/db/migrate/20151101184727_create_tags.rb
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
`latest_migration` is released under the MIT license:
|
|
41
|
+
* http://www.opensource.org/licenses/MIT
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Author
|
|
45
|
+
Arkadiusz Fal
|
|
46
|
+
* http://arekf.net
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Copyright © 2015 Arkadiusz Fal
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'LatestMigration'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
require 'rspec/core/rake_task'
|
|
19
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
20
|
+
rescue LoadError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
task default: [:spec]
|
|
24
|
+
|
|
25
|
+
Bundler::GemHelper.install_tasks
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module LatestMigration
|
|
2
|
+
class Base
|
|
3
|
+
class << self
|
|
4
|
+
def open_latest_migration
|
|
5
|
+
puts "Opening #{latest_migration_filename}"
|
|
6
|
+
system editor_command
|
|
7
|
+
rescue LatestMigration::Errors::MigrationsNotFoundError
|
|
8
|
+
puts "Could not find any migration in this Rails application"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def latest_migration_path
|
|
12
|
+
migrations_filenames.sort.last or fail LatestMigration::Errors::MigrationsNotFoundError
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def editor
|
|
16
|
+
@editor ||= :subl
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attr_writer :editor
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def latest_migration_filename
|
|
24
|
+
File.basename(latest_migration_path)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def editor_command
|
|
28
|
+
"#{editor} #{latest_migration_path}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def migrations_filenames
|
|
32
|
+
Dir.glob(migrations_filename_pattern)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def migrations_filename_pattern
|
|
36
|
+
File.join(migrations_dir_path, "*.rb")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def migrations_dir_path
|
|
40
|
+
dir_path = Rails.root.join("db", "migrate") if defined?(Rails) or fail LatestMigration::Errors::RailsNotFound
|
|
41
|
+
dir_path if Dir.exist?(dir_path) or fail LatestMigration::Errors::MigrationsDirNotFoundError
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module LatestMigration
|
|
2
|
+
module Errors
|
|
3
|
+
class MigrationsNotFoundError < StandardError
|
|
4
|
+
def message
|
|
5
|
+
"Could not find any migration in this Rails application"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class MigrationsDirNotFoundError < StandardError
|
|
10
|
+
def message
|
|
11
|
+
"Could not find migrations directory in this Rails application"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class RailsNotFound < StandardError
|
|
16
|
+
def message
|
|
17
|
+
"Could not load Rails environment"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
namespace :latest_migration do
|
|
2
|
+
desc "Opens latest database migration file in the text editor"
|
|
3
|
+
task open: :environment do
|
|
4
|
+
LatestMigration::Base.open_latest_migration
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
desc "Prints latest database migration file path to the standard output"
|
|
8
|
+
task :path do
|
|
9
|
+
puts LatestMigration::Base.latest_migration_path
|
|
10
|
+
end
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: latest_migration
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Arkadiusz Fal
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: sqlite3
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec-rails
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: codeclimate-test-reporter
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: Provides command to open latest migration file in text editoror just
|
|
70
|
+
display latest migration file path in the standard output.
|
|
71
|
+
email:
|
|
72
|
+
- arek@arekf.net
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- MIT-LICENSE
|
|
78
|
+
- README.md
|
|
79
|
+
- Rakefile
|
|
80
|
+
- lib/latest_migration.rb
|
|
81
|
+
- lib/latest_migration/base.rb
|
|
82
|
+
- lib/latest_migration/errors.rb
|
|
83
|
+
- lib/latest_migration/railtie.rb
|
|
84
|
+
- lib/latest_migration/version.rb
|
|
85
|
+
- lib/tasks/latest_migration_tasks.rake
|
|
86
|
+
homepage: https://github.com/arekf/latest_migration
|
|
87
|
+
licenses:
|
|
88
|
+
- MIT
|
|
89
|
+
metadata: {}
|
|
90
|
+
post_install_message:
|
|
91
|
+
rdoc_options: []
|
|
92
|
+
require_paths:
|
|
93
|
+
- lib
|
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: 2.0.0
|
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
requirements: []
|
|
105
|
+
rubyforge_project:
|
|
106
|
+
rubygems_version: 2.4.5.1
|
|
107
|
+
signing_key:
|
|
108
|
+
specification_version: 4
|
|
109
|
+
summary: Rake task to open latest migration file in text editor
|
|
110
|
+
test_files: []
|