bearonrails 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 +17 -0
- data/.rubocop.yml +30 -0
- data/Gemfile +3 -0
- data/LICENSE +25 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/bearonrails.gemspec +22 -0
- data/bin/bearonrails +14 -0
- data/lib/bearonrails.rb +5 -0
- data/lib/bearonrails/app_builder.rb +68 -0
- data/lib/bearonrails/generators/app_generator.rb +73 -0
- data/lib/bearonrails/version.rb +4 -0
- data/templates/.pryrc +21 -0
- data/templates/.rubocop.yml +27 -0
- data/templates/Gemfile_additions +26 -0
- data/templates/config/initializers/pry.rb +24 -0
- data/templates/spec/rails_helper_addon +10 -0
- data/templates/tasks/dev.rake +8 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3536c28210004fe2996629104d51e8632821a1a5
|
4
|
+
data.tar.gz: 42f5982e6fb5267729cd1b2a400eca356648bd47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d86c2803dcc83aa31c9094ee0a5f32e17cbfdb7ef32c89c03349f0c7e6ac7bf5a6a4d6d2af5dbc5aa63040ffb050726c15fd446c534b9fbbb9bd0217163128db
|
7
|
+
data.tar.gz: 591780bf231d87e4479ee929e0a5fc624d0fcb9b98e5c512887aefa39ca18d42d2d6dba080431e79476c8eb4d88809b2ce3627959d694bc02ec57f7ab2ce510f
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
AllCops:
|
2
|
+
RunRailsCops: true
|
3
|
+
|
4
|
+
Include:
|
5
|
+
- '**/Gemfile'
|
6
|
+
- '**/Rakefile'
|
7
|
+
|
8
|
+
Exclude:
|
9
|
+
- 'bin/*'
|
10
|
+
- 'db/migrate/*'
|
11
|
+
- 'db/seeds.rb'
|
12
|
+
- 'db/schema.rb'
|
13
|
+
- 'vendor/bundle/**/*'
|
14
|
+
|
15
|
+
Metrics/ClassLength:
|
16
|
+
CountComments: false # count full line comments?
|
17
|
+
Max: 150
|
18
|
+
|
19
|
+
Metrics/LineLength:
|
20
|
+
Max: 120
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
CountComments: false # count full line comments?
|
24
|
+
Max: 20
|
25
|
+
|
26
|
+
Style/AsciiComments:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/AccessorMethodName:
|
30
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
License
|
2
|
+
-------
|
3
|
+
|
4
|
+
(The MIT License)
|
5
|
+
|
6
|
+
Copyright (c) 2015 Bear Su (timfanda35)
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
'Software'), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Bearonrails
|
2
|
+
|
3
|
+
Bearonrails is the base Rails application generator.(For Rails 4.2+)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First install the bearonrails gem:
|
8
|
+
|
9
|
+
$ gem install bearonrails
|
10
|
+
|
11
|
+
Then run:
|
12
|
+
|
13
|
+
$ bearonrails project_name
|
14
|
+
|
15
|
+
## Gems
|
16
|
+
|
17
|
+
* [pry-rails](https://github.com/rweng/pry-rails)
|
18
|
+
* [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug)
|
19
|
+
* [awesome_print](https://github.com/michaeldv/awesome_print)
|
20
|
+
* [hirb](https://github.com/cldwalker/hirb)
|
21
|
+
* [hirb-unicode](https://github.com/miaout17/hirb-unicode)
|
22
|
+
* [better_errors](https://github.com/charliesome/better_errors)
|
23
|
+
* [binding_of_caller](https://github.com/banister/binding_of_caller)
|
24
|
+
* [quiet_assets](https://github.com/evrone/quiet_assets)
|
25
|
+
* [capistrano-rails](https://github.com/capistrano/rails/)
|
26
|
+
* [capistrano-bundler](https://github.com/capistrano/bundler/)
|
27
|
+
* [rubocop](https://github.com/bbatsov/rubocop)
|
28
|
+
* [brakeman](https://github.com/presidentbeef/brakeman)
|
29
|
+
* [rspec-rails](https://github.com/rspec/rspec-rails)
|
30
|
+
* [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner)
|
31
|
+
* [factory_girl_rails](https://github.com/thoughtbot/factory_girl_rails)
|
32
|
+
* [faker](https://github.com/stympy/faker)
|
33
|
+
|
34
|
+
## Reference:
|
35
|
+
|
36
|
+
[xdite/bootstrappers](https://github.com/xdite/bootstrappers)
|
37
|
+
|
38
|
+
[超棒的 rails console 設定](http://toyroom.bruceli.net/tw/2014/08/13/awesome-rails-console-customization-using-pry.html)
|
39
|
+
|
40
|
+
|
41
|
+
## MIT License
|
42
|
+
|
data/Rakefile
ADDED
data/bearonrails.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../lib/bearonrails/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'bearonrails'
|
5
|
+
gem.version = Bearonrails::VERSION
|
6
|
+
|
7
|
+
gem.required_ruby_version = '>= 1.9.3'
|
8
|
+
|
9
|
+
gem.license = 'MIT'
|
10
|
+
gem.authors = ['timfanda35']
|
11
|
+
gem.email = ['timfanda35@gmail.com']
|
12
|
+
gem.summary = 'A Base Rails application generator.'
|
13
|
+
gem.description = gem.summary
|
14
|
+
gem.homepage = 'https://github.com/timfanda35/bearonrails'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split("\n").sort
|
17
|
+
gem.executables = ['bearonrails']
|
18
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\\/)
|
19
|
+
gem.require_paths = ['lib']
|
20
|
+
|
21
|
+
gem.add_dependency 'rails', '~>4.2', '>= 4.2.0'
|
22
|
+
end
|
data/bin/bearonrails
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# (C) Bear Su (timfanda35)
|
4
|
+
# MIT license
|
5
|
+
$0 = 'bearonrails'
|
6
|
+
|
7
|
+
require File.expand_path(File.join('..', 'lib', 'bearonrails', 'generators', 'app_generator'), File.dirname(__FILE__))
|
8
|
+
require File.expand_path(File.join('..', 'lib', 'bearonrails', 'app_builder'), File.dirname(__FILE__))
|
9
|
+
|
10
|
+
templates_root = File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
|
11
|
+
|
12
|
+
Bearonrails::AppGenerator.source_root templates_root
|
13
|
+
Bearonrails::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root
|
14
|
+
Bearonrails::AppGenerator.start
|
data/lib/bearonrails.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
module Bearonrails
|
3
|
+
#
|
4
|
+
class AppBuilder < Rails::AppBuilder
|
5
|
+
def add_common_rake_tasks
|
6
|
+
directory 'tasks', 'lib/tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
def init_git
|
10
|
+
run 'git init'
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_custom_gems
|
14
|
+
additions_path = find_in_source_paths 'Gemfile_additions'
|
15
|
+
new_gems = File.open(additions_path).read
|
16
|
+
inject_into_file(
|
17
|
+
'Gemfile',
|
18
|
+
"\n#{new_gems}",
|
19
|
+
after: /^end/
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_rubocop_config
|
24
|
+
copy_file '.rubocop.yml', '.rubocop.yml'
|
25
|
+
end
|
26
|
+
|
27
|
+
def install_rspec
|
28
|
+
run 'bundle exec rails g rspec:install'
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_rspec_helper_addon
|
32
|
+
additions_path = find_in_source_paths 'spec/rails_helper_addon'
|
33
|
+
addon_config = File.open(additions_path).read
|
34
|
+
inject_into_file(
|
35
|
+
'spec/rails_helper.rb',
|
36
|
+
"\n#{addon_config}",
|
37
|
+
before: /^end/
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_routes_comment_lines
|
42
|
+
replace_in_file(
|
43
|
+
'config/routes.rb',
|
44
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
45
|
+
"Rails.application.routes.draw do\nend"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_pryrc
|
50
|
+
copy_file '.pryrc', '.pryrc'
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_pry_config
|
54
|
+
copy_file 'config/initializers/pry.rb', 'config/initializers/pry.rb'
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def replace_in_file(relative_path, find, replace)
|
60
|
+
path = File.join(destination_root, relative_path)
|
61
|
+
contents = IO.read(path)
|
62
|
+
unless contents.gsub!(find, replace)
|
63
|
+
fail "#{find.inspect} not found in #{relative_path}"
|
64
|
+
end
|
65
|
+
File.open(path, 'w') { |file| file.write(contents) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
#
|
5
|
+
module Bearonrails
|
6
|
+
#
|
7
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
8
|
+
def finish_template
|
9
|
+
bearonrails_customization
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def bearonrails_customization
|
14
|
+
invoke :remove_files_we_dont_need
|
15
|
+
invoke :add_common_rake_tasks
|
16
|
+
invoke :customize_gemfile
|
17
|
+
invoke :install_rspec
|
18
|
+
invoke :add_rubocop_config
|
19
|
+
invoke :add_pry_config
|
20
|
+
invoke :remove_routes_comment_lines
|
21
|
+
invoke :init_git
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_files_we_dont_need
|
25
|
+
say 'remove files we don\'t need'
|
26
|
+
build :remove_public_index
|
27
|
+
build :remove_rails_logo_image
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_common_rake_tasks
|
31
|
+
say 'Add common rake tasks'
|
32
|
+
build :add_common_rake_tasks
|
33
|
+
end
|
34
|
+
|
35
|
+
def customize_gemfile
|
36
|
+
build :add_custom_gems
|
37
|
+
bundle_command 'install'
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_rubocop_config
|
41
|
+
say 'Add rubocop config'
|
42
|
+
build :add_rubocop_config
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_pry_config
|
46
|
+
say 'Add pry config'
|
47
|
+
build :add_pryrc
|
48
|
+
build :add_pry_config
|
49
|
+
end
|
50
|
+
|
51
|
+
def install_rspec
|
52
|
+
say 'Install rspec'
|
53
|
+
build :install_rspec
|
54
|
+
build :add_rspec_helper_addon
|
55
|
+
end
|
56
|
+
|
57
|
+
def remove_routes_comment_lines
|
58
|
+
say 'Remove routes comment lines'
|
59
|
+
build :remove_routes_comment_lines
|
60
|
+
end
|
61
|
+
|
62
|
+
def init_git
|
63
|
+
say 'Init git'
|
64
|
+
build :init_git
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def get_builder_class
|
70
|
+
Bearonrails::AppBuilder
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/templates/.pryrc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "awesome_print"
|
2
|
+
AwesomePrint.pry!
|
3
|
+
|
4
|
+
begin
|
5
|
+
require "hirb"
|
6
|
+
require "hirb-unicode"
|
7
|
+
extend Hirb::Console
|
8
|
+
rescue LoadError => e
|
9
|
+
end
|
10
|
+
|
11
|
+
if defined?(PryByebug)
|
12
|
+
Pry.commands.alias_command 'c', 'continue'
|
13
|
+
Pry.commands.alias_command 's', 'step'
|
14
|
+
Pry.commands.alias_command 'n', 'next'
|
15
|
+
Pry.commands.alias_command 'f', 'finish'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Hit Enter to repeat last command
|
19
|
+
Pry::Commands.command /^$/, "repeat last command" do
|
20
|
+
_pry_.run_command Pry.history.to_a.last
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
AllCops:
|
2
|
+
RunRailsCops: true
|
3
|
+
|
4
|
+
Include:
|
5
|
+
- '**/Gemfile'
|
6
|
+
- '**/Rakefile'
|
7
|
+
|
8
|
+
Exclude:
|
9
|
+
- 'bin/*'
|
10
|
+
- 'db/migrate/*'
|
11
|
+
- 'db/seeds.rb'
|
12
|
+
- 'db/schema.rb'
|
13
|
+
- 'vendor/bundle/**/*'
|
14
|
+
|
15
|
+
Metrics/ClassLength:
|
16
|
+
CountComments: false # count full line comments?
|
17
|
+
Max: 150
|
18
|
+
|
19
|
+
Metrics/LineLength:
|
20
|
+
Max: 120
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
CountComments: false # count full line comments?
|
24
|
+
Max: 20
|
25
|
+
|
26
|
+
Style/AsciiComments:
|
27
|
+
Enabled: false
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
gem 'pry'
|
3
|
+
gem 'pry-byebug'
|
4
|
+
gem 'awesome_print', :require => false
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'hirb', :require => false
|
8
|
+
gem 'hirb-unicode', :require => false
|
9
|
+
end
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem 'better_errors'
|
13
|
+
gem 'binding_of_caller'
|
14
|
+
gem 'quiet_assets'
|
15
|
+
gem 'capistrano-rails'
|
16
|
+
gem 'capistrano-bundler'
|
17
|
+
gem 'rubocop', require: false
|
18
|
+
gem 'brakeman', require: false
|
19
|
+
end
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
gem 'rspec-rails'
|
23
|
+
gem 'database_cleaner'
|
24
|
+
gem 'factory_girl_rails'
|
25
|
+
gem 'faker'
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
## config/initializers/pry.rb
|
2
|
+
## encoding: utf-8
|
3
|
+
## 預設的 prompt_name 是 pry,下面這行會把 prompt_name 變成該 project 的名稱 (自動抓)
|
4
|
+
Pry.config.prompt_name = Rails.application.class.parent_name.underscore.dasherize
|
5
|
+
|
6
|
+
unless Rails.env.development?
|
7
|
+
old_prompt = Pry.config.prompt
|
8
|
+
|
9
|
+
if Rails.env.production?
|
10
|
+
# 這邊本來應該是 Pry::Helpers::Text.red(Rails.env.upcase)
|
11
|
+
# 相當於 "\e[0;31m#{Rails.env.upcase}\e[0m"
|
12
|
+
# 但因為一個 readline 引起的 bug 導致輸入游標錯位,因此需加上 \001 \002 來跳過此問題,下同
|
13
|
+
# 此問題的討論串在 https://github.com/pry/pry/issues/493
|
14
|
+
env = "\001\e[0;31m\002#{Rails.env.upcase}\001\e[0m\002" # 紅色 的 env 名稱
|
15
|
+
else
|
16
|
+
env = "\001\e[0;33m\002#{Rails.env.upcase}\001\e[0m\002" # 黃色 的 env 名稱
|
17
|
+
end
|
18
|
+
|
19
|
+
# 替換 pry prompt 的方法在 https://github.com/pry/pry/wiki/Customization-and-configuration#Config_prompt 有教學
|
20
|
+
Pry.config.prompt = [
|
21
|
+
proc { |*a| "#{env} #{old_prompt.first.call(*a)}" },
|
22
|
+
proc { |*a| "#{env} #{old_prompt.second.call(*a)}" }
|
23
|
+
]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bearonrails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- timfanda35
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-24 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: '4.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.2.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.2.0
|
33
|
+
description: A Base Rails application generator.
|
34
|
+
email:
|
35
|
+
- timfanda35@gmail.com
|
36
|
+
executables:
|
37
|
+
- bearonrails
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- ".gitignore"
|
42
|
+
- ".rubocop.yml"
|
43
|
+
- Gemfile
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- bearonrails.gemspec
|
48
|
+
- bin/bearonrails
|
49
|
+
- lib/bearonrails.rb
|
50
|
+
- lib/bearonrails/app_builder.rb
|
51
|
+
- lib/bearonrails/generators/app_generator.rb
|
52
|
+
- lib/bearonrails/version.rb
|
53
|
+
- templates/.pryrc
|
54
|
+
- templates/.rubocop.yml
|
55
|
+
- templates/Gemfile_additions
|
56
|
+
- templates/config/initializers/pry.rb
|
57
|
+
- templates/spec/rails_helper_addon
|
58
|
+
- templates/tasks/dev.rake
|
59
|
+
homepage: https://github.com/timfanda35/bearonrails
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 1.9.3
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: A Base Rails application generator.
|
83
|
+
test_files: []
|
84
|
+
has_rdoc:
|