multi_ar 6.0.0.pre.beta → 6.0.0.pre.rc

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4be873bd564b04b81d3a4245160c98007dec42edb692cabf64ce1a4ae3e2b5ef
4
- data.tar.gz: c33cbbed7eea9697166655ba9952e3155048c156975c82a20413bd99bb86b366
3
+ metadata.gz: 864f23be74df421560dbc71fc150ebad7e7d1984c6b40ffec8812c960c1f577f
4
+ data.tar.gz: 4fc6df8964c097198b9cce2a536c2df462624882ef3837e1cc28402e6bd0438a
5
5
  SHA512:
6
- metadata.gz: e6a1152839e3967942d039eac8f6bc91a9ac572fe804f9d0cf1bbbc9aa040428d858350c5ed49d2dbcc3c2e0876bbc7a2801f606fb15876d2332e380d728af6f
7
- data.tar.gz: 9ece6a831414d6bfbbdaf168db31e219ef3f161b31ad36e046da51f2244e2c06269da387217cd4250d7b96c81fa79cb665150afeb95a5d70a3db43623d9bb607
6
+ metadata.gz: 602f1193b42ae49ea30ee2f09ac014cce308518294e9e160ed9569fff18a13f0cf63b32f4289b6f13257f51eda8658ce57afbab10228da8a97e3c0f618c794f4
7
+ data.tar.gz: 2ab89db6d8613a79c52ef3c62aa6caebb9fc67853eb18e89630fd4be33334312e5dcdcf7c6ac56bd8920f24c25d05ef5e48f8e2436956e590bc3f5e665f74790
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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 must be given when bootstrapping." unless opts["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
- FileUtils.mkdir opts["init"] unless Dir.exist? opts["init"]
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}/, "")
@@ -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
- # add new rename method to Rake::Task class
25
- # to rename a task
26
- class Rake::Task
27
- # Renames current Rake task.
28
- def rename(new_name)
29
- if !new_name.nil?
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
- if old_name == new_name
33
- return
34
- end
33
+ if old_name == new_name
34
+ return
35
+ end
35
36
 
36
- @name = new_name.to_s
37
- application.rename_task(self, old_name, new_name)
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
@@ -51,9 +51,7 @@ module Rake
51
51
  end
52
52
 
53
53
  class << self
54
- attr_accessor :databases
55
54
  attr_accessor :environment
56
- attr_accessor :common_migrations
57
55
  end
58
56
 
59
57
  # When called, this declares Rake tasks of MultiAR,
@@ -1,4 +1,5 @@
1
1
 
2
2
  module MultiAR
3
- VERSION = "6.0.0-beta"
3
+ # MultiAR’s current version.
4
+ VERSION = "6.0.0-rc"
4
5
  end
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.beta
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-28 00:00:00.000000000 Z
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