communard 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d160711820fe427786947a0718c53cb73a2167df5fb714196ffc81e77fe148a
4
- data.tar.gz: 5642f174554fbbdbf006726823d34e582f5b0791fa1e5ee86541fd69f3ec8c3e
3
+ metadata.gz: f086c0a2c7f0988d298bdcd68152554e54bec59a2b85eeca132110958a26f8cb
4
+ data.tar.gz: 816c4d1bc57fa5f1bce109f4bd684c00db9d8bcecfbbf6b8de5a3513f42ed3f1
5
5
  SHA512:
6
- metadata.gz: 0a5811b7dd25ef9aba12a113b12b8b50b22a176c7023ed190356eee6e874840ec0c6a99476252401bef88a06eddc158bb875c4beed249036ebb5286c52544af8
7
- data.tar.gz: b098d85743d78519bcb4e57e08dfedc0c574237e3600d97af023524b2ec0a2740c511c153de01681d1cc6c4efe49caa619aa6c7045cb714d72cfe63e693ab692
6
+ metadata.gz: d1a267acc98b76429df1a667ca24baee1ce2f7994c49a91c6465332f9c37ff41f0199b19b19760b1f2e2493f601462b7ef710524048eb323ebb935fd7e136274
7
+ data.tar.gz: 07647b8d8a88d8cd3907f1d56c1974643ee03445ae9c3df5d070ba48cf3c443747245c98b3ccc74d2f3b2356e06189c5ad7b2b5fffaffbf8abc3250f35f2b353
data/README.md CHANGED
@@ -59,8 +59,8 @@ Other configuration options, can be set via a block:
59
59
  namespace :db do
60
60
  Communard::Rake.add_tasks do |config|
61
61
 
62
- # Change where the application is located, defaults to Dir.pwd
63
- config.root_path = Dir.pwd
62
+ # Change where the application is located (default: db)
63
+ config.db_path = File.join(Dir.pwd, "db")
64
64
 
65
65
  # Automatically generate schema (default: false)
66
66
  config.dump_after_migrating = false
@@ -12,7 +12,7 @@ module Communard
12
12
  :adapter,
13
13
  :database_name,
14
14
  :options,
15
- :root_path
15
+ :db_path
16
16
 
17
17
  def initialize(configuration)
18
18
  @configuration = configuration
@@ -49,6 +49,10 @@ module Communard
49
49
  load seeds_file if seeds_file.exist?
50
50
  end
51
51
 
52
+ def check_current
53
+ Sequel::Migrator.check_current(connection, migrations_dir)
54
+ end
55
+
52
56
  def rollback(step: 1)
53
57
  available = applied_migrations
54
58
  if available.size == 1
@@ -122,15 +126,15 @@ module Communard
122
126
  end
123
127
 
124
128
  def schema_file
125
- root_path.join("db/schema.rb")
129
+ db_path.join("schema.rb")
126
130
  end
127
131
 
128
132
  def seeds_file
129
- root_path.join("db/seeds.rb")
133
+ db_path.join("seeds.rb")
130
134
  end
131
135
 
132
136
  def migrations_dir
133
- root_path.join("db/migrate")
137
+ db_path.join("migrate")
134
138
  end
135
139
 
136
140
  Status = Struct.new(:file, :applied, :available) do
@@ -28,7 +28,7 @@ module Communard
28
28
  raise ArgumentError, "Sequel::Database.connect takes either a Hash or a String, given: #{conn_string.inspect}"
29
29
  end
30
30
 
31
- self.root_path = Dir.pwd
31
+ self.db_path = Pathname(Dir.pwd).join("db")
32
32
  self.logger = nil
33
33
  self.dump_after_migrating = true
34
34
  self.same_db = true
@@ -42,10 +42,10 @@ module Communard
42
42
 
43
43
  attr_accessor :dump_after_migrating
44
44
 
45
- attr_reader :root_path
45
+ attr_reader :db_path
46
46
 
47
- def root_path=(path)
48
- @root_path = Pathname(path)
47
+ def db_path=(path)
48
+ @db_path = Pathname(path)
49
49
  end
50
50
 
51
51
  def connection
@@ -43,6 +43,11 @@ module Communard
43
43
  @_communard_commands.rollback(step: step)
44
44
  end
45
45
 
46
+ desc "Checks if the database is fully migrated"
47
+ task check_current: :_load_communard do
48
+ @_communard_commands.check_current
49
+ end
50
+
46
51
  namespace :test do
47
52
  desc "Cleans the test database"
48
53
  task prepare: :_load_communard do
@@ -52,7 +57,8 @@ module Communard
52
57
  "RUBY_ENV" => "test",
53
58
  "DATABASE_URL" => nil,
54
59
  }
55
- Process.spawn(env, $PROGRAM_NAME, "db:drop", "db:create", "db:schema:load")
60
+ cmd = @_communard_commands.schema_file.exist? ? "db:schema:load" : "db:migrate"
61
+ Process.spawn(env, $PROGRAM_NAME, "db:drop", "db:create", cmd)
56
62
  _pid, status = Process.wait2
57
63
  fail "Failed to re-create test database" if status.exitstatus != 0
58
64
  end
@@ -1,5 +1,5 @@
1
1
  module Communard
2
2
 
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: communard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-12 00:00:00.000000000 Z
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel