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 +4 -4
- data/README.md +2 -2
- data/lib/communard/commands.rb +8 -4
- data/lib/communard/configuration.rb +4 -4
- data/lib/communard/rake.rb +7 -1
- data/lib/communard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f086c0a2c7f0988d298bdcd68152554e54bec59a2b85eeca132110958a26f8cb
|
4
|
+
data.tar.gz: 816c4d1bc57fa5f1bce109f4bd684c00db9d8bcecfbbf6b8de5a3513f42ed3f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
63
|
-
config.
|
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
|
data/lib/communard/commands.rb
CHANGED
@@ -12,7 +12,7 @@ module Communard
|
|
12
12
|
:adapter,
|
13
13
|
:database_name,
|
14
14
|
:options,
|
15
|
-
:
|
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
|
-
|
129
|
+
db_path.join("schema.rb")
|
126
130
|
end
|
127
131
|
|
128
132
|
def seeds_file
|
129
|
-
|
133
|
+
db_path.join("seeds.rb")
|
130
134
|
end
|
131
135
|
|
132
136
|
def migrations_dir
|
133
|
-
|
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.
|
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 :
|
45
|
+
attr_reader :db_path
|
46
46
|
|
47
|
-
def
|
48
|
-
@
|
47
|
+
def db_path=(path)
|
48
|
+
@db_path = Pathname(path)
|
49
49
|
end
|
50
50
|
|
51
51
|
def connection
|
data/lib/communard/rake.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/communard/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|