ridgepoler-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +27 -0
- data/config/initializers/i18n.rb +5 -0
- data/config/initializers/meta_tags.rb +6 -0
- data/config/initializers/premailer.rb +8 -0
- data/config/initializers/webpack.rb +4 -0
- data/lib/generators/rails/ridgepole/USAGE +8 -0
- data/lib/generators/rails/ridgepole/ridgepole_generator.rb +20 -0
- data/lib/generators/rails/ridgepole/templates/schema.rb +24 -0
- data/lib/generators/ridgepole/install/install_generator.rb +13 -0
- data/lib/generators/ridgepole/install/templates/db/Schemafile +8 -0
- data/lib/ridgepoler/rails/config.rb +38 -0
- data/lib/ridgepoler/rails/railtie.rb +14 -0
- data/lib/ridgepoler/rails/tasks/override.rake +31 -0
- data/lib/ridgepoler/rails/tasks/ridgepole.rake +36 -0
- data/lib/ridgepoler/rails/version.rb +5 -0
- data/lib/ridgepoler/rails.rb +3 -0
- data/lib/ridgepoler-rails.rb +1 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc5bf61b19055f85a8e25f0736c4151318b018f7
|
4
|
+
data.tar.gz: 9a5c5f3d5a2c5be8cc9ffce54a457143b8cb7ba1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71abbabdd349d48bcdfac8078d5ed6f7a67aeafbd0e339cc21acbd536e7e7d1b334132291d689dcb6cf2a2640280e9eb28398112b90fb31afa1b744439095acd
|
7
|
+
data.tar.gz: 88c5d2689c6a2b7f63629fbcc6e2d058ec00ffd3c1ddb8944d8223e585e5cf9ead3e25022a082b593591a5ec18a605e365ee5ac4ec910af5476b580f63ab828f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Sho Kusano
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Ridgepoler::Rails
|
2
|
+
|
3
|
+
Provides integration between ridgepole and rails 5 newer.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ridgepoler-rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle install
|
17
|
+
$ bundle exec rails generate ridgepole:install
|
18
|
+
```
|
19
|
+
|
20
|
+
## Generators
|
21
|
+
|
22
|
+
Once installed, Ridgepoler will generate migration files instead of ActiveRecord migration files when commands like `rails generate model` be used.
|
23
|
+
|
24
|
+
## Rake tasks
|
25
|
+
|
26
|
+
Ridgepoler will replace or clear some db tasks. If you doesn't need that overrides, you can set `config.ridgepoler.override_db_tasks = false`.
|
27
|
+
|
28
|
+
### Clear tasks
|
29
|
+
|
30
|
+
- `db:migrate:status`
|
31
|
+
- `db:rollback`
|
32
|
+
- `db:schema:cache:clear`
|
33
|
+
- `db:schema:cache:dump`
|
34
|
+
- `db:schema:dump`
|
35
|
+
- `db:schema:load`
|
36
|
+
- `db:structure:dump`
|
37
|
+
- `db:structure:load`
|
38
|
+
- `db:version`
|
39
|
+
|
40
|
+
### Override tasks
|
41
|
+
|
42
|
+
- `db:migrate` => `ridgepole:apply`
|
43
|
+
- `db:setup` => `ridgepole:setup`
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/space-pirates-llc/ridgepoler-rails/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Ridgepoler::Rails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/active_record/model/model_generator'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Generators
|
7
|
+
class RidgepoleGenerator < ActiveRecord::Generators::ModelGenerator
|
8
|
+
def self.source_paths
|
9
|
+
[ActiveRecord::Generators::ModelGenerator.source_root, File.expand_path('../templates', __FILE__)]
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_migration_file
|
13
|
+
return unless options[:migration] && options[:parent].nil?
|
14
|
+
attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false
|
15
|
+
|
16
|
+
template 'schema.rb', File.join('db/schema', class_path, "#{file_name}.rb")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
create_table :<%= table_name %><%= primary_key_type %>, force: :cascade do |t|
|
4
|
+
<% attributes.each do |attribute| -%>
|
5
|
+
<% if attribute.password_digest? -%>
|
6
|
+
t.string :password_digest<%= attribute.inject_options %>
|
7
|
+
<% elsif attribute.token? -%>
|
8
|
+
t.string :<%= attribute.name %><%= attribute.inject_options %>
|
9
|
+
<% else -%>
|
10
|
+
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
11
|
+
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
<% if options[:timestamps] %>
|
14
|
+
t.datetime :created_at, null: false
|
15
|
+
t.datetime :updated_at, null: false
|
16
|
+
<% end -%>
|
17
|
+
end
|
18
|
+
|
19
|
+
<% attributes.select(&:token?).each do |attribute| -%>
|
20
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
21
|
+
<% end -%>
|
22
|
+
<% attributes_with_index.each do |attribute| -%>
|
23
|
+
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
24
|
+
<% end -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ridgepole
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
def self.source_root
|
5
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def copy_schemafile
|
9
|
+
template 'db/Schemafile'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'ridgepoler/rails'
|
2
|
+
|
3
|
+
class Ridgepoler::Rails::Config
|
4
|
+
def debug
|
5
|
+
return @debug if instance_variable_defined?(:@debug)
|
6
|
+
|
7
|
+
@debug = false
|
8
|
+
end
|
9
|
+
attr_writer :debug
|
10
|
+
|
11
|
+
def verbose
|
12
|
+
return @verbose if instance_variable_defined?(:@verbose)
|
13
|
+
|
14
|
+
@verbose = false
|
15
|
+
end
|
16
|
+
attr_writer :verbose
|
17
|
+
|
18
|
+
def options
|
19
|
+
return @options if instance_variable_defined?(:@options)
|
20
|
+
|
21
|
+
@options = []
|
22
|
+
end
|
23
|
+
attr_writer :options
|
24
|
+
|
25
|
+
def root
|
26
|
+
return @root if instance_variable_defined?(:@root)
|
27
|
+
|
28
|
+
@root = 'db/Schemafile'
|
29
|
+
end
|
30
|
+
attr_writer :root
|
31
|
+
|
32
|
+
def override_db_tasks
|
33
|
+
return @override_db_tasks if instance_variable_defined?(:@override_db_tasks)
|
34
|
+
|
35
|
+
@override_db_tasks = true
|
36
|
+
end
|
37
|
+
attr_writer :override_db_tasks
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'ridgepoler/rails'
|
3
|
+
require 'ridgepoler/rails/config'
|
4
|
+
|
5
|
+
class Ridgepoler::Rails::Railtie < ::Rails::Railtie
|
6
|
+
config.app_generators.orm :ridgepole
|
7
|
+
|
8
|
+
config.ridgepole = Ridgepoler::Rails::Config.new
|
9
|
+
|
10
|
+
rake_tasks do
|
11
|
+
load File.join(File.dirname(__FILE__), 'tasks', 'ridgepole.rake')
|
12
|
+
load File.join(File.dirname(__FILE__), 'tasks', 'override.rake') if Rails.application.config.ridgepole.override_db_tasks
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
%w[
|
4
|
+
db:migrate
|
5
|
+
db:migrate:status
|
6
|
+
db:rollback
|
7
|
+
db:schema:cache:clear
|
8
|
+
db:schema:cache:dump
|
9
|
+
db:schema:dump
|
10
|
+
db:schema:load
|
11
|
+
db:setup
|
12
|
+
db:structure:dump
|
13
|
+
db:structure:load
|
14
|
+
db:version
|
15
|
+
].each do |task|
|
16
|
+
Rake::Task[task].clear
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :db do
|
20
|
+
def alias_task(new, old)
|
21
|
+
desc Rake::Task[old].comment
|
22
|
+
task new, [*Rake.application[old].arg_names] => [old]
|
23
|
+
end
|
24
|
+
|
25
|
+
{
|
26
|
+
:migrate => 'ridgepole:apply',
|
27
|
+
:setup => 'ridgepole:setup',
|
28
|
+
}.each_pair do |new, old|
|
29
|
+
alias_task(new, old)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :ridgepole do
|
4
|
+
desc 'Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)'
|
5
|
+
task setup: ['db:create', 'ridgepole:apply', 'db:seed']
|
6
|
+
|
7
|
+
desc 'Migrate the database'
|
8
|
+
task apply: [:environment] do
|
9
|
+
ridgepole(env: Rails.env)
|
10
|
+
ridgepole(env: 'test') if Rails.env.development?
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Display status of migrations'
|
14
|
+
task check: [:environment] do
|
15
|
+
ridgepole(env: Rails.env, dry_run: true)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def ridgepole(env: Rails.env, dry_run: false)
|
21
|
+
args = ['ridgepole', '-a', '-c', 'config/database.yml', '-E', env]
|
22
|
+
args.push('--dry-run') if dry_run
|
23
|
+
args.push('--debug') if config.debug
|
24
|
+
args.push('--verbose') if config.verbose
|
25
|
+
|
26
|
+
args += config.options
|
27
|
+
|
28
|
+
args.push('-f', config.root)
|
29
|
+
|
30
|
+
sh(*args)
|
31
|
+
end
|
32
|
+
|
33
|
+
def config
|
34
|
+
Rails.application.config.ridgepole
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'ridgepoler/rails'
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ridgepoler-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sho Kusano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.3'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.3'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ridgepole
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: Provides integration between ridgepole and rails 5 newer
|
62
|
+
email:
|
63
|
+
- sho-kusano@space-pirates.jp
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- MIT-LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- config/initializers/i18n.rb
|
72
|
+
- config/initializers/meta_tags.rb
|
73
|
+
- config/initializers/premailer.rb
|
74
|
+
- config/initializers/webpack.rb
|
75
|
+
- lib/generators/rails/ridgepole/USAGE
|
76
|
+
- lib/generators/rails/ridgepole/ridgepole_generator.rb
|
77
|
+
- lib/generators/rails/ridgepole/templates/schema.rb
|
78
|
+
- lib/generators/ridgepole/install/install_generator.rb
|
79
|
+
- lib/generators/ridgepole/install/templates/db/Schemafile
|
80
|
+
- lib/ridgepoler-rails.rb
|
81
|
+
- lib/ridgepoler/rails.rb
|
82
|
+
- lib/ridgepoler/rails/config.rb
|
83
|
+
- lib/ridgepoler/rails/railtie.rb
|
84
|
+
- lib/ridgepoler/rails/tasks/override.rake
|
85
|
+
- lib/ridgepoler/rails/tasks/ridgepole.rake
|
86
|
+
- lib/ridgepoler/rails/version.rb
|
87
|
+
homepage: https://github.com/space-pirates-llc/ridgepoler-rails
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.6.8
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Provides integration between ridgepole and rails 5 newer
|
111
|
+
test_files: []
|