multi_ar 6.0.0.pre.beta → 6.0.0.pre.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/multi_ar/interface.rb +37 -4
- data/lib/multi_ar/rake/ext.rb +17 -13
- data/lib/multi_ar/rake/migration_generator.rb +7 -0
- data/lib/multi_ar/rake/tasks.rb +0 -2
- data/lib/multi_ar/version.rb +2 -1
- data/lib/multi_ar.rb +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864f23be74df421560dbc71fc150ebad7e7d1984c6b40ffec8812c960c1f577f
|
4
|
+
data.tar.gz: 4fc6df8964c097198b9cce2a536c2df462624882ef3837e1cc28402e6bd0438a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602f1193b42ae49ea30ee2f09ac014cce308518294e9e160ed9569fff18a13f0cf63b32f4289b6f13257f51eda8658ce57afbab10228da8a97e3c0f618c794f4
|
7
|
+
data.tar.gz: 2ab89db6d8613a79c52ef3c62aa6caebb9fc67853eb18e89630fd4be33334312e5dcdcf7c6ac56bd8920f24c25d05ef5e48f8e2436956e590bc3f5e665f74790
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/multi_ar/interface.rb
CHANGED
@@ -55,6 +55,7 @@ module MultiAR
|
|
55
55
|
@run_by_default = false
|
56
56
|
end
|
57
57
|
|
58
|
+
# Default location of database configuration.
|
58
59
|
DEFAULT_DB_CONFIG = "config/database.yaml"
|
59
60
|
|
60
61
|
# @note Consumes ARGV, create copy of it if you need it for something.
|
@@ -107,7 +108,7 @@ module MultiAR
|
|
107
108
|
bootstrap opts if opts["init"] # Bootstrap will exit after execution; in that case nothing after this will be run.
|
108
109
|
|
109
110
|
raise "--config must be path to valid file" if opts[:config_given] and not File.exist? opts["config"]
|
110
|
-
raise "Database config #{opts["db_config"]} seems to be missing" if @options["db_config"] and not File.exist? opts["db_config"]
|
111
|
+
raise "Database config #{opts["db_config"]} seems to be missing. See --help for usage." if @options["db_config"] and not File.exist? opts["db_config"]
|
111
112
|
|
112
113
|
@opts = opts
|
113
114
|
|
@@ -166,16 +167,19 @@ module MultiAR
|
|
166
167
|
|
167
168
|
# @note This method will always quit the application or raise another exception for errors. Catch SystemExit if that’s not good for you.
|
168
169
|
def bootstrap opts
|
169
|
-
raise "--databases
|
170
|
+
raise "Please specify --databases for your new project. See --help." unless opts["databases"]
|
170
171
|
#raise "#{opts["init"]} already exists" if File.exist? opts["init"] # We don’t want to actually check it, init is more like “add missing configuration”.
|
171
172
|
|
172
173
|
config_dir = "config"
|
173
174
|
database_config = "database.yaml"
|
174
175
|
|
175
|
-
|
176
|
+
puts opts.inspect
|
177
|
+
execute_bundle_gem opts if not Dir.exist? opts["init"]
|
178
|
+
|
179
|
+
#FileUtils.mkdir opts["init"] unless Dir.exist? opts["init"]
|
176
180
|
Dir.chdir opts["init"] do
|
177
181
|
File.write "README.md", bootstrap_readme(opts) unless File.exist?("README.md")
|
178
|
-
bootstrap_gemfile
|
182
|
+
#bootstrap_gemfile
|
179
183
|
|
180
184
|
FileUtils.mkdir config_dir unless Dir.exist? config_dir
|
181
185
|
Dir.chdir config_dir do
|
@@ -191,6 +195,17 @@ module MultiAR
|
|
191
195
|
exit 0
|
192
196
|
end
|
193
197
|
|
198
|
+
def execute_bundle_gem opts
|
199
|
+
project_name = opts["init"]
|
200
|
+
`bundle gem #{project_name}`
|
201
|
+
# There is some custom files I rather have.
|
202
|
+
Dir.chdir project_name do
|
203
|
+
FileUtils.rm "README.md"
|
204
|
+
|
205
|
+
bootstrap_gemspec opts
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
194
209
|
def bootstrap_db_config opts
|
195
210
|
str = ""
|
196
211
|
databases = parse_databases_input(opts["databases"])
|
@@ -220,6 +235,24 @@ module MultiAR
|
|
220
235
|
end
|
221
236
|
end
|
222
237
|
|
238
|
+
def bootstrap_gemspec opts
|
239
|
+
project_name = opts["init"]
|
240
|
+
gemspec = "#{project_name}.gemspec"
|
241
|
+
|
242
|
+
lines = File.readlines gemspec
|
243
|
+
puts lines.inspect
|
244
|
+
raise "Generated gemspec was not as expected..." if lines[-1] != "end\n"
|
245
|
+
lines.insert -2, " spec.add_runtime_dependency \"multi_ar\", \"~> #{::MultiAR::VERSION}\""
|
246
|
+
lines.insert -2, " spec.add_development_dependency \"multi_ar_migrations\", \"~> #{::MultiAR::VERSION}\""
|
247
|
+
|
248
|
+
puts lines.inspect
|
249
|
+
|
250
|
+
File.open gemspec, "w" do |f|
|
251
|
+
f.puts lines
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# TODO: this is deprecated and not in use
|
223
256
|
def bootstrap_gemfile
|
224
257
|
|
225
258
|
str = <<-EOS.gsub(/^ {6}/, "")
|
data/lib/multi_ar/rake/ext.rb
CHANGED
@@ -2,10 +2,13 @@
|
|
2
2
|
require "rake"
|
3
3
|
|
4
4
|
# @api private
|
5
|
+
#
|
5
6
|
# Extension to Rake to provide rename task.
|
6
7
|
module Rake
|
8
|
+
|
7
9
|
# Extension to Rake to provide rename task.
|
8
10
|
class Application
|
11
|
+
|
9
12
|
# A Rake task to rename another Rake task.
|
10
13
|
def rename_task(task, oldname, newname)
|
11
14
|
if @tasks.nil?
|
@@ -19,23 +22,24 @@ module Rake
|
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
22
|
-
end
|
23
25
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
old_name = @name
|
26
|
+
# Adds new method, rename, to Rake::Task class to rename a task.
|
27
|
+
class Task
|
28
|
+
# Renames current Rake task.
|
29
|
+
def rename(new_name)
|
30
|
+
if !new_name.nil?
|
31
|
+
old_name = @name
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
if old_name == new_name
|
34
|
+
return
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
@name = new_name.to_s
|
38
|
+
application.rename_task(self, old_name, new_name)
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
44
|
+
|
45
|
+
|
@@ -4,11 +4,18 @@ require "active_record/tasks/database_tasks"
|
|
4
4
|
|
5
5
|
|
6
6
|
# @api private
|
7
|
+
#
|
8
|
+
# Overridden from Active Record to have custom migration path.
|
7
9
|
module ActiveRecordMigrations
|
10
|
+
|
11
|
+
# Overridden from Active Record to have custom migration path.
|
8
12
|
module Generators
|
13
|
+
|
14
|
+
# Overridden from Active Record to have custom migration path.
|
9
15
|
class MigrationGenerator < ::ActiveRecord::Generators::MigrationGenerator
|
10
16
|
source_root ::ActiveRecord::Generators::MigrationGenerator.source_root
|
11
17
|
|
18
|
+
# Overridden from Active Record to have custom migration path.
|
12
19
|
def db_migrate_path
|
13
20
|
database_name = MultiAR::MultiAR::databases.first[0]
|
14
21
|
MultiAR::MultiAR::solve_migration_path database_name
|
data/lib/multi_ar/rake/tasks.rb
CHANGED
data/lib/multi_ar/version.rb
CHANGED
data/lib/multi_ar.rb
CHANGED
@@ -100,6 +100,7 @@ module MultiAR
|
|
100
100
|
ActiveRecord::Tasks::DatabaseTasks.migrations_paths
|
101
101
|
end
|
102
102
|
|
103
|
+
# Calculates path to migration dir for given database.
|
103
104
|
def self.migration_dir_for database_name
|
104
105
|
ActiveRecord::Tasks::DatabaseTasks.migrations_paths
|
105
106
|
end
|
@@ -144,6 +145,9 @@ module MultiAR
|
|
144
145
|
@rake.invoke_task task_name
|
145
146
|
end
|
146
147
|
|
148
|
+
# @api private
|
149
|
+
#
|
150
|
+
# Returns internal databases array.
|
147
151
|
def self.databases
|
148
152
|
@@__databases
|
149
153
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_ar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.pre.
|
4
|
+
version: 6.0.0.pre.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samu Voutilainen
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
OzjdOT7AkCnpLgMDZSIHOoDc3iydYxJAgo5iAkXVMHZJQ2IfZRoEIAHsE3yeLK7H
|
35
35
|
37jzNNQuoDPqiNcASg0XaZAxvWI=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2019-08
|
37
|
+
date: 2019-09-08 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: optimist
|
metadata.gz.sig
CHANGED
Binary file
|