latest_migration 0.1 → 0.2
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 +4 -4
- data/README.md +2 -2
- data/lib/latest_migration.rb +1 -1
- data/lib/latest_migration/base.rb +7 -18
- data/lib/latest_migration/errors.rb +4 -10
- data/lib/latest_migration/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 867c900a2a79606c355eb0d568b55103a4d11dbb
|
|
4
|
+
data.tar.gz: b5b8edb6bc56498eef6b6b7d1eb1a74298d22f9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8b37003fec74d8316f2fdf89011c7ab88900e70e6822dcfb812fa27a120558041bcddc266ab48cfefce2603f8e6d54c1bcfa951467dbd85b022a4178cd135c1
|
|
7
|
+
data.tar.gz: 916bdae822957e8475ef67b39ff40c07f4432a5ba3d021bf98042a82ecd21f71c8313a7c1822bcc6160a7c0a8a00683c380e2c57f56eab9efa7d3724fe6ce937
|
data/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
# latest_migration
|
|
4
4
|
|
|
5
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
|
|
6
|
+
migration file in text editor. It saves the time of selecting, copying
|
|
7
7
|
and opening the file in your editor.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
* Add `latest_migration` to your Gemfile:
|
|
11
11
|
```ruby
|
|
12
|
-
gem 'latest_migration', group: development
|
|
12
|
+
gem 'latest_migration', group: :development
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
* Install with: bundle install
|
data/lib/latest_migration.rb
CHANGED
|
@@ -4,12 +4,13 @@ module LatestMigration
|
|
|
4
4
|
def open_latest_migration
|
|
5
5
|
puts "Opening #{latest_migration_filename}"
|
|
6
6
|
system editor_command
|
|
7
|
-
rescue LatestMigration::Errors::MigrationsNotFoundError
|
|
8
|
-
puts
|
|
7
|
+
rescue LatestMigration::Errors::MigrationsNotFoundError => e
|
|
8
|
+
puts e
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def latest_migration_path
|
|
12
|
-
|
|
12
|
+
filename = latest_migration_filename
|
|
13
|
+
File.join(Rails.root, filename)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def editor
|
|
@@ -20,25 +21,13 @@ module LatestMigration
|
|
|
20
21
|
|
|
21
22
|
private
|
|
22
23
|
|
|
23
|
-
def latest_migration_filename
|
|
24
|
-
File.basename(latest_migration_path)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
24
|
def editor_command
|
|
28
25
|
"#{editor} #{latest_migration_path}"
|
|
29
26
|
end
|
|
30
27
|
|
|
31
|
-
def
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
28
|
+
def latest_migration_filename
|
|
29
|
+
filename = ActiveRecord::Migrator.migrations(ActiveRecord::Migrator.migrations_path).last.try(:filename)
|
|
30
|
+
filename or fail LatestMigration::Errors::MigrationsNotFoundError
|
|
42
31
|
end
|
|
43
32
|
end
|
|
44
33
|
end
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
module LatestMigration
|
|
2
2
|
module Errors
|
|
3
3
|
class MigrationsNotFoundError < StandardError
|
|
4
|
-
def
|
|
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"
|
|
4
|
+
def initialize
|
|
5
|
+
super("Could not find any migration in this Rails application")
|
|
12
6
|
end
|
|
13
7
|
end
|
|
14
8
|
|
|
15
9
|
class RailsNotFound < StandardError
|
|
16
|
-
def
|
|
17
|
-
"Could not load Rails environment"
|
|
10
|
+
def initialize
|
|
11
|
+
super("Could not load Rails environment")
|
|
18
12
|
end
|
|
19
13
|
end
|
|
20
14
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: latest_migration
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arkadiusz Fal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|