multi_tenancy_database 0.1.1
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 +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/multi_tenancy_database +6 -0
- data/lib/multi_tenancy_database/command.rb +73 -0
- data/lib/multi_tenancy_database/generator.rb +297 -0
- data/lib/multi_tenancy_database/version.rb +3 -0
- data/lib/multi_tenancy_database.rb +13 -0
- data/multi_tenancy_database.gemspec +42 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2813e27322bc7bca485ca23f1279798edbc98cab
|
4
|
+
data.tar.gz: 01d2f8c3d6ad76ce167642a10f83222fce071d15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4bd26e6dc0f1d291e526e2444db19e3e9f0ed3c3e87e84cd3b2bffefa86448603ad02f5f7bff195c6e26b7b302e0623e10c4ea51401624ccfe2e6ec42f18e511
|
7
|
+
data.tar.gz: 6e82a972d72d3a16e57c2f7886fc28b5d49ccb6f7306eb2938bd45f95894316baa25a635590ff19ebefcff6bae81f97b08f468650bc38e3773492f645ed4d30d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# MultiTenancyDatabase
|
2
|
+
|
3
|
+
Allowing multiple databases to connect to the same project and still use ActiveRecord to perform operations on the models
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'multi_tenancy_database'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install multi_tenancy_database
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In this example, we’ll have a separate database for our e-commerce school that we’ll call school.
|
24
|
+
|
25
|
+
### Add new database
|
26
|
+
|
27
|
+
multi_tenancy_database -n school -a postgresql
|
28
|
+
|
29
|
+
### Create Database
|
30
|
+
|
31
|
+
rails school:db:create
|
32
|
+
|
33
|
+
### Create new model
|
34
|
+
|
35
|
+
rails g school_model user first_name:string last_name:string
|
36
|
+
|
37
|
+
### Add more field to model user
|
38
|
+
|
39
|
+
rails g school_migration AddPhoneFieldToUser phone:string
|
40
|
+
|
41
|
+
### Migrate
|
42
|
+
|
43
|
+
rails school:db:migrate
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "multi_tenancy_database"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'multi_tenancy_database'
|
3
|
+
require 'multi_tenancy_database/version'
|
4
|
+
|
5
|
+
module MultiTenancyDatabase
|
6
|
+
class Command
|
7
|
+
def initialize(args)
|
8
|
+
args << '-h' if args.empty?
|
9
|
+
@args = args
|
10
|
+
@options = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
@opts = OptionParser.new(&method(:set_opts))
|
15
|
+
@opts.parse!(@args)
|
16
|
+
check_missing_requirement_options
|
17
|
+
process!
|
18
|
+
exit 0
|
19
|
+
rescue Exception => ex
|
20
|
+
raise ex if @options[:trace] || SystemExit === ex
|
21
|
+
$stderr.print "#{ex.class}: " if ex.class != RuntimeError
|
22
|
+
$stderr.puts ex.message
|
23
|
+
$stderr.puts ' Use --trace for backtrace.'
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
def check_missing_requirement_options
|
29
|
+
mandatory = [:name, :adapter]
|
30
|
+
missing = mandatory.select{ |param| @options[param].nil? }
|
31
|
+
if !missing.empty?
|
32
|
+
puts "Missing options: #{missing.join(', ')}"
|
33
|
+
puts @opts.help
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def command_name
|
39
|
+
@command_name ||= 'multi_tenancy_database'
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_opts(opts)
|
43
|
+
opts.banner = "Usage: #{command_name} [options]"
|
44
|
+
|
45
|
+
opts.on('--trace', :NONE, 'Show a full traceback on error') do
|
46
|
+
@options[:trace] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('-n', '--name=db_name', 'Database name') do |name|
|
50
|
+
@options[:name] = name.gsub(/^\=+/, '')
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-a', '--adapter=posttgresql|mysql', 'Adapter type') do |adapter|
|
54
|
+
@options[:adapter] = adapter.gsub(/^\=+/, '')
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on_tail('-v', '--version', 'Print version') do
|
58
|
+
puts "#{command_name} #{MultiTenancyDatabase::VERSION}"
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
63
|
+
puts opts
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def process!
|
69
|
+
args = @args.dup
|
70
|
+
MultiTenancyDatabase.generator!(@options)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
require 'multi_tenancy_database'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module MultiTenancyDatabase
|
5
|
+
class Generator
|
6
|
+
def initialize(args)
|
7
|
+
@template_path = "#{__dir__}/templates"
|
8
|
+
@options = args
|
9
|
+
@current_dir = get_current_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
puts 'Starting generate database'
|
14
|
+
puts '1. Create config connect to new database'
|
15
|
+
copy_config
|
16
|
+
puts '2. Created migration'
|
17
|
+
copy_migrate
|
18
|
+
puts '3. Created generation command'
|
19
|
+
copy_libs_generators
|
20
|
+
puts '4. Created tasks'
|
21
|
+
copy_libs_tasks
|
22
|
+
puts '5. Created module model'
|
23
|
+
copy_model
|
24
|
+
puts 'Done generate database'
|
25
|
+
show_summary
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def show_summary
|
30
|
+
puts %Q(Please fill user/password connect to database database_#{database_name}.
|
31
|
+
To create new model for database #{database_name}:
|
32
|
+
rails g #{database_name}_model <model-name> field:type[, ....]
|
33
|
+
Ex: rails g #{database_name}_model user name:string address:string
|
34
|
+
To create new migration for model #{database_name}:
|
35
|
+
rails g #{database_name}_migration <migration-name> field:type[, ....]
|
36
|
+
Ex: rails g #{database_name}_migration AddPhoneFieldToUser phone:string
|
37
|
+
To run migration
|
38
|
+
rails g #{database_name}:db:migrate
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def copy_config
|
43
|
+
dir = "#{@current_dir}/config/"
|
44
|
+
FileUtils.mkdir_p("#{dir}databases")
|
45
|
+
|
46
|
+
puts "\t.Created database_#{database_name}.yml"
|
47
|
+
f = File.open("#{dir}databases/database_#{database_name}.yml", 'w')
|
48
|
+
f.puts database_config_template
|
49
|
+
f.close
|
50
|
+
|
51
|
+
f = File.open("#{dir}initializers/db_#{database_name}.rb", 'w')
|
52
|
+
f.puts constant_template
|
53
|
+
f.close
|
54
|
+
end
|
55
|
+
|
56
|
+
def constant_template
|
57
|
+
%Q(config=YAML::load(ERB.new(File.read(Rails.root.join('config','databases/database_#{database_name}.yml'))).result)
|
58
|
+
#{database_name.upcase}_DB = config[Rails.env]
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def database_config_template
|
63
|
+
%Q(default: &default
|
64
|
+
adapter: #{adapter}
|
65
|
+
encoding: unicode
|
66
|
+
# For details on connection pooling, see Rails configuration guide
|
67
|
+
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
68
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
69
|
+
|
70
|
+
development:
|
71
|
+
<<: *default
|
72
|
+
username: <%= ENV['DEV_DATABASE_#{database_name.upcase}_USERNAME'] %>
|
73
|
+
password: <%= ENV['DEV_DATABASE_#{database_name.upcase}_PASSWORD'] %>
|
74
|
+
database: #{database_name}_dev
|
75
|
+
|
76
|
+
test:
|
77
|
+
<<: *default
|
78
|
+
username: <%= ENV['TEST_DATABASE_#{database_name.upcase}_USERNAME'] %>
|
79
|
+
password: <%= ENV['TEST_DATABASE_#{database_name.upcase}_PASSWORD'] %>
|
80
|
+
database: #{database_name}_test
|
81
|
+
|
82
|
+
production:
|
83
|
+
<<: *default
|
84
|
+
username: <%= ENV['PROD_DATABASE_#{database_name.upcase}_USERNAME'] %>
|
85
|
+
password: <%= ENV['PROD_DATABASE_#{database_name.upcase}_PASSWORD'] %>
|
86
|
+
database: #{database_name}_prod
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def copy_model
|
91
|
+
dir = "#{@current_dir}/app/models/#{database_name}_db"
|
92
|
+
FileUtils.mkdir_p("#{dir}")
|
93
|
+
f = File.open("#{dir}/base.rb", 'w')
|
94
|
+
f.puts base_template_content
|
95
|
+
f.close
|
96
|
+
end
|
97
|
+
|
98
|
+
def base_template_content
|
99
|
+
%Q(module #{camelize}Db
|
100
|
+
class Base < ActiveRecord::Base
|
101
|
+
self.abstract_class = true
|
102
|
+
establish_connection #{database_name.upcase}_DB
|
103
|
+
end
|
104
|
+
end
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def copy_libs_tasks
|
109
|
+
dir = "#{@current_dir}/lib/"
|
110
|
+
FileUtils.mkdir_p("#{dir}/tasks")
|
111
|
+
|
112
|
+
f = File.open("#{dir}/tasks/db_#{database_name}.rake", 'w')
|
113
|
+
f.puts rake_template_content
|
114
|
+
f.close
|
115
|
+
end
|
116
|
+
|
117
|
+
def copy_libs_generators
|
118
|
+
dir = "#{@current_dir}/lib/"
|
119
|
+
FileUtils.mkdir_p("#{dir}/generators/templates")
|
120
|
+
|
121
|
+
puts "\t.Created template #{database_name}_db_model.rb"
|
122
|
+
f = File.open("#{dir}/generators/templates/#{database_name}_db_model.rb.tt", 'w')
|
123
|
+
f.puts model_template_content
|
124
|
+
f.close
|
125
|
+
|
126
|
+
puts "\t.Created template #{database_name}_migration_generator.rb"
|
127
|
+
f = File.open("#{dir}/generators/#{database_name}_migration_generator.rb", 'w')
|
128
|
+
f.puts migration_generation
|
129
|
+
f.close
|
130
|
+
|
131
|
+
puts "\t.Created template #{database_name}_model_generator.rb"
|
132
|
+
f = File.open("#{dir}/generators/#{database_name}_model_generator.rb", 'w')
|
133
|
+
f.puts model_generation
|
134
|
+
f.close
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def rake_template_content
|
139
|
+
%Q(task spec: ['#{database_name}:db:test:prepare']
|
140
|
+
|
141
|
+
namespace :#{database_name} do
|
142
|
+
namespace :db do |ns|
|
143
|
+
%i(drop create setup migrate rollback seed version).each do |task_name|
|
144
|
+
task task_name do
|
145
|
+
Rake::Task["db:\#{task_name}"].invoke
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
namespace :schema do
|
150
|
+
%i(load dump).each do |task_name|
|
151
|
+
task task_name do
|
152
|
+
Rake::Task["db:schema:\#{task_name}"].invoke
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
namespace :test do
|
158
|
+
task :prepare do
|
159
|
+
Rake::Task['db:test:prepare'].invoke
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# append and prepend proper tasks to all the tasks defined here above
|
164
|
+
ns.tasks.each do |task|
|
165
|
+
task.enhance ['#{database_name}:set_custom_config'] do
|
166
|
+
Rake::Task['#{database_name}:revert_to_original_config'].invoke
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
task :set_custom_config do
|
172
|
+
# save current vars
|
173
|
+
@original_config = {
|
174
|
+
env_schema: ENV['SCHEMA'],
|
175
|
+
config: Rails.application.config.dup
|
176
|
+
}
|
177
|
+
|
178
|
+
# set config variables for custom database
|
179
|
+
ENV['SCHEMA'] = 'db/#{database_name}s/schema.rb'
|
180
|
+
Rails.application.config.paths['db'] = ['db/#{database_name}s']
|
181
|
+
Rails.application.config.paths['db/migrate'] = ['db/#{database_name}s/migrate']
|
182
|
+
# If you are using Rails 5 or higher change `paths['db/seeds']` to `paths['db/seeds.rb']`
|
183
|
+
Rails.application.config.paths['db/seeds'] = ['db/#{database_name}s/seeds.rb']
|
184
|
+
Rails.application.config.paths['config/database'] = ['config/databases/database_#{database_name}.yml']
|
185
|
+
end
|
186
|
+
|
187
|
+
task :revert_to_original_config do
|
188
|
+
# reset config variables to original values
|
189
|
+
ENV['SCHEMA'] = @original_config[:env_schema]
|
190
|
+
Rails.application.config = @original_config[:config]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
def model_generation
|
197
|
+
%Q(require 'rails/generators/active_record/model/model_generator'
|
198
|
+
|
199
|
+
class #{camelize}ModelGenerator < ActiveRecord::Generators::ModelGenerator
|
200
|
+
ActiveRecord::Generators::ModelGenerator
|
201
|
+
.instance_method(:create_model_file)
|
202
|
+
|
203
|
+
migration_file = File.dirname(
|
204
|
+
ActiveRecord::Generators::ModelGenerator
|
205
|
+
.instance_method(:create_migration_file)
|
206
|
+
.source_location.first
|
207
|
+
)
|
208
|
+
|
209
|
+
source_root File.join(migration_file, "templates")
|
210
|
+
|
211
|
+
def create_migration_file
|
212
|
+
return unless options[:migration] && options[:parent].nil?
|
213
|
+
attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
|
214
|
+
migration_template "../../migration/templates/create_table_migration.rb", File.join('db/#{database_name}s/migrate', "create_\#{table_name}.rb")
|
215
|
+
end
|
216
|
+
|
217
|
+
def create_model_file
|
218
|
+
template Rails.root.join('lib', 'generators', "templates", "#{database_name}_db_model.rb"), File.join("app/models", class_path, "\#{file_name}.rb")
|
219
|
+
end
|
220
|
+
end
|
221
|
+
)
|
222
|
+
end
|
223
|
+
|
224
|
+
def migration_generation
|
225
|
+
%Q(require 'rails/generators/active_record/migration/migration_generator'
|
226
|
+
|
227
|
+
class #{camelize}MigrationGenerator < ActiveRecord::Generators::MigrationGenerator
|
228
|
+
migration_file = File.dirname(
|
229
|
+
ActiveRecord::Generators::MigrationGenerator
|
230
|
+
.instance_method(:create_migration_file)
|
231
|
+
.source_location.first
|
232
|
+
)
|
233
|
+
|
234
|
+
source_root File.join(migration_file, "templates")
|
235
|
+
|
236
|
+
def create_migration_file
|
237
|
+
set_local_assigns!
|
238
|
+
validate_file_name!
|
239
|
+
migration_template @migration_template, "db/#{database_name}s/migrate/\#{file_name}.rb"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
)
|
243
|
+
end
|
244
|
+
|
245
|
+
def model_template_content
|
246
|
+
%Q(<% module_namespacing do -%>
|
247
|
+
class <%= class_name %> < #{camelize}Db::Base
|
248
|
+
<% attributes.select(&:reference?).each do |attribute| -%>
|
249
|
+
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
|
250
|
+
<% end -%>
|
251
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
252
|
+
has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
|
253
|
+
<% end -%>
|
254
|
+
<% if attributes.any?(&:password_digest?) -%>
|
255
|
+
has_secure_password
|
256
|
+
<% end -%>
|
257
|
+
end
|
258
|
+
<% end -%>
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
def copy_migrate
|
263
|
+
dir = "#{@current_dir}/db/#{database_name}s"
|
264
|
+
FileUtils.mkdir_p("#{dir}/migrate")
|
265
|
+
|
266
|
+
f = File.open("#{dir}/schema.rb", 'w')
|
267
|
+
f.close
|
268
|
+
|
269
|
+
f = File.open("#{dir}/seed.rb", 'w')
|
270
|
+
f.close
|
271
|
+
end
|
272
|
+
|
273
|
+
def camelize
|
274
|
+
database_name.split('_').map {|w| w.capitalize}.join
|
275
|
+
end
|
276
|
+
|
277
|
+
def database_name
|
278
|
+
@options[:name].downcase
|
279
|
+
end
|
280
|
+
|
281
|
+
def adapter
|
282
|
+
@options[:adapter].downcase
|
283
|
+
end
|
284
|
+
|
285
|
+
def get_current_dir
|
286
|
+
if defined?(Rails)
|
287
|
+
return Rails.root
|
288
|
+
end
|
289
|
+
|
290
|
+
if defined?(Bundler)
|
291
|
+
return Bundler.root
|
292
|
+
end
|
293
|
+
|
294
|
+
Dir.pwd
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "multi_tenancy_database/version"
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
require_relative 'multi_tenancy_database/version'
|
5
|
+
require_relative 'multi_tenancy_database/command'
|
6
|
+
require_relative 'multi_tenancy_database/generator'
|
7
|
+
|
8
|
+
module MultiTenancyDatabase
|
9
|
+
class Error < StandardError; end
|
10
|
+
def self.generator!(options)
|
11
|
+
MultiTenancyDatabase::Generator.new(options).run
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "multi_tenancy_database/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "multi_tenancy_database"
|
8
|
+
spec.version = MultiTenancyDatabase::VERSION
|
9
|
+
spec.authors = ["thuocsi.vn"]
|
10
|
+
spec.email = ["phuong@thuocsi.vn"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate and connect database}
|
13
|
+
spec.description = %q{Generate new config datanbase and add this conneect to currentt project}
|
14
|
+
spec.homepage = "https://github.com/thuocsi/multi_tenancy_database"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/thuocsi/multi_tenancy_database"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/thuocsi/multi_tenancy_database"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = ['multi_tenancy_database']
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: multi_tenancy_database
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thuocsi.vn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Generate new config datanbase and add this conneect to currentt project
|
56
|
+
email:
|
57
|
+
- phuong@thuocsi.vn
|
58
|
+
executables:
|
59
|
+
- multi_tenancy_database
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- exe/multi_tenancy_database
|
72
|
+
- lib/multi_tenancy_database.rb
|
73
|
+
- lib/multi_tenancy_database/command.rb
|
74
|
+
- lib/multi_tenancy_database/generator.rb
|
75
|
+
- lib/multi_tenancy_database/version.rb
|
76
|
+
- multi_tenancy_database.gemspec
|
77
|
+
homepage: https://github.com/thuocsi/multi_tenancy_database
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata:
|
81
|
+
homepage_uri: https://github.com/thuocsi/multi_tenancy_database
|
82
|
+
source_code_uri: https://github.com/thuocsi/multi_tenancy_database
|
83
|
+
changelog_uri: https://github.com/thuocsi/multi_tenancy_database
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.5.2.3
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Generate and connect database
|
104
|
+
test_files: []
|