migrext 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.
Files changed (2) hide show
  1. data/lib/migrext/rails.rb +5 -3
  2. metadata +2 -2
data/lib/migrext/rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  require 'yaml'
3
+ require 'pathname'
3
4
 
4
5
  module MigrExt
5
6
  class RailsApplication
@@ -23,10 +24,11 @@ module MigrExt
23
24
  end
24
25
 
25
26
  def create_migration!(version, name, content)
26
- filename = "#@base_dir/db/migrate/#{version}_#{name.underscore}.rb"
27
- raise RuntimeError, "Migration #{version}:#{name} exist" if File.exist?(filename)
27
+ filepath = Pathname.new("#@base_dir/db/migrate/#{version}_#{name.underscore}.rb")
28
+ raise RuntimeError, "Migration #{version}:#{name} exist" if filepath.exist?
28
29
 
29
- File.open(filename, "w") {|f| f.write content }
30
+ filepath.dirname.mkpath
31
+ filepath.open("w") {|f| f.write content }
30
32
  @current_migrations = nil
31
33
  end
32
34
 
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ version: "0.2"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Ayose Cazorla