bankai 0.1.0
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 +13 -0
- data/.overcommit.yml +22 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bankai.gemspec +38 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/bankai +27 -0
- data/lib/bankai/builder.rb +82 -0
- data/lib/bankai/generator.rb +99 -0
- data/lib/bankai/generators/base.rb +20 -0
- data/lib/bankai/generators/ci_generator.rb +30 -0
- data/lib/bankai/generators/db_optimizations_generator.rb +33 -0
- data/lib/bankai/generators/deploy_generator.rb +45 -0
- data/lib/bankai/generators/json_generator.rb +15 -0
- data/lib/bankai/generators/lint_generator.rb +26 -0
- data/lib/bankai/generators/mailer_generator.rb +29 -0
- data/lib/bankai/generators/testing_generator.rb +35 -0
- data/lib/bankai/version.rb +7 -0
- data/lib/bankai.rb +10 -0
- data/templates/Gemfile.erb +110 -0
- data/templates/README.md.erb +233 -0
- data/templates/deploy.rb.erb +43 -0
- data/templates/dotfiles/.ctags +2 -0
- data/templates/dotfiles/.env.example +4 -0
- data/templates/gitignore.erb +61 -0
- data/templates/gitlab-ci.yml.erb +74 -0
- data/templates/overcommit.yml.erb +23 -0
- data/templates/rack_mini_profiler.rb +5 -0
- data/templates/rails_helper.rb +32 -0
- data/templates/rubocop.yml.erb +37 -0
- data/templates/spec/database_rewinder.rb +11 -0
- data/templates/spec/shoulda_matchers.rb +8 -0
- data/templates/spec_helper.rb +20 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e905c9f83697a55d0db35a69fe1437e420b4d9f6a27095b157f72885768c0483
|
4
|
+
data.tar.gz: 2cbedd82cd3a99958eb6e15f2388cafed89ee8682c6144140bb1e956ac9ed487
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: edbcb5487f470a20e1fa77cf09f5020333e24e3c7366de4280ad08f06c01e36009aed7fa984858e1a3d8fbeb4d22cdb161d99d79a002cfed54fe2e104d69395c
|
7
|
+
data.tar.gz: a13a69b17f57e57dba179202218835efe837704102ff8739dbb39d4c6194b26a4418b7b7fd76de3f9a9a1f2bda01d4da2c1d104675fbff2637a308805da1f01a
|
data/.gitignore
ADDED
data/.overcommit.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PreCommit:
|
2
|
+
AuthorName:
|
3
|
+
enabled: false
|
4
|
+
RuboCop:
|
5
|
+
enabled: true
|
6
|
+
on_warn: fail # Treat all warnings as failures
|
7
|
+
TrailingWhitespace:
|
8
|
+
enabled: true
|
9
|
+
exclude:
|
10
|
+
- '.licenses/**/*'
|
11
|
+
|
12
|
+
PrePush:
|
13
|
+
BundleAudit:
|
14
|
+
enabled: true
|
15
|
+
BundleOutdated:
|
16
|
+
enabled: true
|
17
|
+
|
18
|
+
PostCheckout:
|
19
|
+
ALL: # Special hook name that customizes all hooks of this type
|
20
|
+
quiet: true # Change all post-checkout hooks to only display output on failure
|
21
|
+
IndexTags:
|
22
|
+
enabled: true # Generate a tags file with `ctags` each time HEAD changes
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at elct9620@frost.tw. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Ruby5x
|
2
|
+
===
|
3
|
+
|
4
|
+
This gem is inspired by [Suspenders](https://github.com/thoughtbot/suspenders) for [5xRuby](https://5xruby.tw) to bootstrap a rails project.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
First, install bankai
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install bankai
|
12
|
+
```
|
13
|
+
|
14
|
+
The bootstrap your rails project
|
15
|
+
|
16
|
+
```
|
17
|
+
bankai projectname
|
18
|
+
```
|
19
|
+
|
20
|
+
## Gemfile
|
21
|
+
|
22
|
+
* [Oj](http://www.ohler.com/oj/)
|
23
|
+
|
24
|
+
### Development
|
25
|
+
|
26
|
+
* [Brakeman](https://github.com/presidentbeef/brakeman)
|
27
|
+
* [Bundler Audit](https://github.com/rubysec/bundler-audit)
|
28
|
+
* [Rubocop](https://github.com/bbatsov/rubocop)
|
29
|
+
* [Rack Mini Profiler](https://github.com/MiniProfiler/rack-mini-profiler) - Enable with `RACK_MINI_PROFILER=1`
|
30
|
+
* [Annotate](https://github.com/ctran/annotate_models)
|
31
|
+
* [Bullet](https://github.com/flyerhzm/bullet)
|
32
|
+
* [Dotenv](https://github.com/bkeepers/dotenv)
|
33
|
+
* [Letter Opener](https://github.com/ryanb/letter_opener)
|
34
|
+
* [Overcommit](https://github.com/brigade/overcommit)
|
35
|
+
* [Pry Rails](https://github.com/rweng/pry-rails)
|
36
|
+
|
37
|
+
### Test
|
38
|
+
|
39
|
+
* [Capybara](https://github.com/jnicklas/capybara)
|
40
|
+
* [Google Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/home)
|
41
|
+
* [Factory Bot](https://github.com/thoughtbot/factory_bot)
|
42
|
+
* [Faker](https://github.com/stympy/faker)
|
43
|
+
* [Rspec](https://github.com/rspec/rspec)
|
44
|
+
* [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers)
|
45
|
+
* [Simplecov](https://github.com/colszowka/simplecov) - Enable with `COVERAGE=1`
|
46
|
+
|
47
|
+
## Others
|
48
|
+
|
49
|
+
* Configured `.gitlab-ci.yml`
|
50
|
+
* Auto filled capistrano configure
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
### Test Gem
|
59
|
+
|
60
|
+
If you want to test the changes for generator is works well, you can add `--path` options to use your local version
|
61
|
+
|
62
|
+
```
|
63
|
+
bankai projectname --path=YOUR_LOCAL_GEM_PATH
|
64
|
+
```
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/5xRuby/bankai. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
69
|
+
|
70
|
+
## Code of Conduct
|
71
|
+
|
72
|
+
Everyone interacting in the Bankai project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/5xRuby/bankai/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bankai.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'bankai/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.required_ruby_version = ">= #{Bankai::RUBY_VERSION}"
|
9
|
+
spec.name = 'bankai'
|
10
|
+
spec.version = Bankai::VERSION
|
11
|
+
spec.authors = %w[5xRuby 蒼時弦也]
|
12
|
+
spec.email = ['hi@5xruby.tw', 'contact0@frost.tw']
|
13
|
+
|
14
|
+
spec.summary = 'The Rails template for 5xRuby'
|
15
|
+
spec.description = 'The tool to generate Rails template for 5xRuby'
|
16
|
+
spec.homepage = 'https://github.com/5xRuby/bankai'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the
|
20
|
+
# RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`
|
23
|
+
.split("\x0")
|
24
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
31
|
+
spec.add_development_dependency 'bundler-audit'
|
32
|
+
spec.add_development_dependency 'overcommit'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 0.60.0'
|
36
|
+
spec.add_development_dependency 'simplecov'
|
37
|
+
spec.add_dependency 'rails', Bankai::RAILS_VERSION
|
38
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'bankai'
|
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
data/exe/bankai
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
5
|
+
$LOAD_PATH << source_path
|
6
|
+
|
7
|
+
require 'bankai'
|
8
|
+
|
9
|
+
if ARGV.empty?
|
10
|
+
puts 'Please provide a path for the new application'
|
11
|
+
puts
|
12
|
+
puts 'See --help for more info'
|
13
|
+
exit 0
|
14
|
+
elsif ['-v', '--version'].include? ARGV[0]
|
15
|
+
puts Bankai::VERSION
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
19
|
+
templates_root = File.expand_path(
|
20
|
+
File.join('..', 'templates'),
|
21
|
+
File.dirname(__FILE__)
|
22
|
+
)
|
23
|
+
Bankai::Generator.source_root templates_root
|
24
|
+
Bankai::Generator.source_paths << Rails::Generators::AppGenerator.source_root
|
25
|
+
Bankai::Generator.source_paths << templates_root
|
26
|
+
|
27
|
+
Bankai::Generator.start
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bankai
|
4
|
+
# :nodoc:
|
5
|
+
class Builder < Rails::AppBuilder
|
6
|
+
def readme
|
7
|
+
template 'README.md.erb', 'README.md'
|
8
|
+
end
|
9
|
+
|
10
|
+
def gitignore
|
11
|
+
template 'gitignore.erb', '.gitignore'
|
12
|
+
end
|
13
|
+
|
14
|
+
def gemfile
|
15
|
+
template 'Gemfile.erb', 'Gemfile'
|
16
|
+
end
|
17
|
+
|
18
|
+
def replace_gemfile(path)
|
19
|
+
template 'Gemfile.erb', 'Gemfile', force: true do |content|
|
20
|
+
if path
|
21
|
+
content.gsub(/gem .bankai./) { |s| %(#{s}, path: "#{path}") }
|
22
|
+
else
|
23
|
+
content
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure_quiet_assets
|
29
|
+
config = <<-RUBY
|
30
|
+
config.assets.quiet = true
|
31
|
+
RUBY
|
32
|
+
|
33
|
+
inject_into_class 'config/application.rb', 'Application', config
|
34
|
+
end
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/MethodLength
|
37
|
+
def configure_generators
|
38
|
+
config = <<-RUBY
|
39
|
+
config.generators do |generate|
|
40
|
+
generate.helper false
|
41
|
+
generate.javascripts false
|
42
|
+
generate.request_specs false
|
43
|
+
generate.routing_specs false
|
44
|
+
generate.stylesheets false
|
45
|
+
generate.test_framework :rspec
|
46
|
+
generate.view_specs false
|
47
|
+
end
|
48
|
+
RUBY
|
49
|
+
|
50
|
+
inject_into_class 'config/application.rb', 'Application', config
|
51
|
+
end
|
52
|
+
|
53
|
+
def setup_default_directories
|
54
|
+
[
|
55
|
+
'spec/lib',
|
56
|
+
'spec/controllers',
|
57
|
+
'spec/helpers',
|
58
|
+
'spec/support/matchers',
|
59
|
+
'spec/support/mixins',
|
60
|
+
'spec/support/shared_examples'
|
61
|
+
].each do |dir|
|
62
|
+
empty_directory_with_keep_file dir
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# rubocop:enable Metrics/MethodLength
|
66
|
+
|
67
|
+
def clear_seed_file
|
68
|
+
File.write(destination_root + '/db/seeds.rb', '')
|
69
|
+
end
|
70
|
+
|
71
|
+
def setup_rack_mini_profiler
|
72
|
+
copy_file(
|
73
|
+
'rack_mini_profiler.rb',
|
74
|
+
'config/initializers/rack_mini_profiler.rb'
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def copy_dotfiles
|
79
|
+
directory('dotfiles', '.')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/rails/app/app_generator'
|
5
|
+
|
6
|
+
module Bankai
|
7
|
+
# :nodoc:
|
8
|
+
class Generator < Rails::Generators::AppGenerator
|
9
|
+
hide!
|
10
|
+
|
11
|
+
class_option :database, type: :string, aliases: '-d', default: 'postgresql',
|
12
|
+
desc: 'Configure for selected database ' \
|
13
|
+
"(options: #{DATABASES.join('/')})"
|
14
|
+
|
15
|
+
class_option :skip_test, type: :boolean, default: true,
|
16
|
+
desc: 'Skip test files'
|
17
|
+
|
18
|
+
class_option :skip_coffee, type: :boolean, default: true,
|
19
|
+
desc: "Don't use CoffeeScript"
|
20
|
+
|
21
|
+
class_option :skip_capistrano, type: :boolean, default: false,
|
22
|
+
desc: "Don't use Capistrano"
|
23
|
+
|
24
|
+
class_option :skip_rspec, type: :boolean, default: false,
|
25
|
+
desc: 'Skip rspec files'
|
26
|
+
|
27
|
+
class_option :path, type: :string, default: nil,
|
28
|
+
desc: 'Path to the gem'
|
29
|
+
|
30
|
+
def finish_template
|
31
|
+
invoke :customization
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def customization
|
36
|
+
invoke :customize_gemfile
|
37
|
+
invoke :setup_development_environment
|
38
|
+
invoke :configure_app
|
39
|
+
invoke :setup_dotfiles
|
40
|
+
invoke :generate_default
|
41
|
+
invoke :setup_default_directories
|
42
|
+
end
|
43
|
+
|
44
|
+
def customize_gemfile
|
45
|
+
build :replace_gemfile, options[:path]
|
46
|
+
bundle_command 'install'
|
47
|
+
end
|
48
|
+
|
49
|
+
def setup_development_environment
|
50
|
+
say 'Setting up the development environment'
|
51
|
+
build :configure_quiet_assets
|
52
|
+
build :configure_generators
|
53
|
+
build :clear_seed_file
|
54
|
+
# TODO: Add setup script
|
55
|
+
end
|
56
|
+
|
57
|
+
def configure_app
|
58
|
+
say 'Configuring app'
|
59
|
+
# TODO: Configure ActionMailer
|
60
|
+
build :setup_rack_mini_profiler
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup_dotfiles
|
64
|
+
build :copy_dotfiles
|
65
|
+
end
|
66
|
+
|
67
|
+
def generate_default
|
68
|
+
run('spring stop')
|
69
|
+
generate('bankai:testing') unless options[:skip_rspec]
|
70
|
+
generate('bankai:ci')
|
71
|
+
generate('bankai:json')
|
72
|
+
generate('bankai:db_optimizations')
|
73
|
+
generate('bankai:mailer')
|
74
|
+
generate('bankai:deploy') unless options[:skip_capistrano]
|
75
|
+
generate('annotate:install')
|
76
|
+
generate('bankai:lint')
|
77
|
+
end
|
78
|
+
|
79
|
+
def setup_default_directories
|
80
|
+
build :setup_default_directories
|
81
|
+
end
|
82
|
+
|
83
|
+
def depends_on_system_test?
|
84
|
+
!(options[:skip_system_test] || options[:skip_rspec] || options[:api])
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.banner
|
88
|
+
"bankai #{arguments.map(&:usage).join(' ')} [options]"
|
89
|
+
end
|
90
|
+
|
91
|
+
protected
|
92
|
+
|
93
|
+
# rubocop:disable Naming/AccessorMethodName
|
94
|
+
def get_builder_class
|
95
|
+
Bankai::Builder
|
96
|
+
end
|
97
|
+
# rubocop:enable Naming/AccessorMethodName
|
98
|
+
end
|
99
|
+
end
|