barebones 0.1.3.1 → 0.1.4.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 +4 -4
- data/LICENSE +1 -1
- data/README.md +22 -28
- data/barebones.gemspec +2 -2
- data/lib/barebones/builders/app_builder.rb +54 -25
- data/lib/barebones/generators/app_generator.rb +24 -28
- data/lib/barebones/version.rb +2 -2
- data/templates/Gemfile.erb +7 -6
- data/templates/api_defaults_concern.rb +6 -6
- data/templates/barebones_gitignore +3 -0
- data/templates/{routes.rb → routes.rb.erb} +5 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a988c36235dab45a627cc23debab190cc764bed2
|
4
|
+
data.tar.gz: c5af15d12f523821efd1e3de6d0667a2ce5e0b68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5634b9a32c3124dd5daf89e5ab1f7bd48694fd7ba1f4e9188590f0e3e695cf576e37d85eace995cfacd8cd327dbe650d46ac4dde659050e410f444741a4aa300
|
7
|
+
data.tar.gz: 874f53019d2958fca3630a5a051d02f331842265cb6f5de56ee80fa18a0efe3d99ac8e6656b1fc73cb8285e1f6e274e7b41b964a053304d1a30fb9a0ebcdbbd9
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -5,8 +5,7 @@ Barebones is my personal base Rails application. After developing a
|
|
5
5
|
couple of Rails applications, I thought that there were some common
|
6
6
|
gems and patterns that would be nice to have out of the box.
|
7
7
|
|
8
|
-
Installation
|
9
|
-
---
|
8
|
+
#Installation
|
10
9
|
Install the gem:
|
11
10
|
|
12
11
|
gem install barebones
|
@@ -15,72 +14,67 @@ Then run:
|
|
15
14
|
|
16
15
|
barebones [AppName]
|
17
16
|
|
18
|
-
|
17
|
+
## Flags
|
19
18
|
If you don't like using any of the below gems or configurations for whatever reason, you can skip them:
|
20
19
|
* --skip-api
|
21
|
-
* --skip-sorcery
|
22
|
-
* --skip-minitest
|
23
20
|
* --skip-resque
|
21
|
+
* --skip-minitest
|
22
|
+
* --skip-factory-girl
|
24
23
|
* --skip-carrierwave
|
25
24
|
|
26
25
|
For example:
|
27
26
|
|
28
|
-
barebones [AppName] --skip-api --skip-
|
27
|
+
barebones [AppName] --skip-api --skip-minitest
|
29
28
|
|
30
|
-
Gemfile
|
31
|
-
---
|
29
|
+
#Gemfile
|
32
30
|
Barebones' [Gemfile](templates/Gemfile.erb) includes various preconfigured gems such as:
|
33
|
-
|
31
|
+
##File Uploading
|
34
32
|
* [Carrierwave](https://github.com/carrierwaveuploader/carrierwave) for file uploading
|
35
33
|
* [Fog](https://github.com/fog/fog) for AWS/Google cloud storage
|
36
34
|
* [MiniMagick](https://github.com/minimagick/minimagick) for image cropping/resizing and all that good stuff
|
37
35
|
|
38
|
-
|
36
|
+
##Background Processing
|
39
37
|
* [Resque](https://github.com/resque/resque) for background workers
|
40
38
|
* [Resque-Scheduler](https://github.com/resque/resque-scheduler) for queueing workers in the future
|
41
39
|
|
42
|
-
|
40
|
+
##Database
|
43
41
|
* [Postgres](https://rubygems.org/gems/pg/versions/0.18.3)
|
44
42
|
|
45
|
-
|
43
|
+
##Dev/Testing
|
46
44
|
* [Byebug](https://github.com/deivid-rodriguez/byebug) for debugging
|
47
45
|
* [Pry Byebug](https://github.com/deivid-rodriguez/pry-byebug) for debugging background jobs
|
48
46
|
* [Web Console](https://github.com/rails/web-console) for debugging views
|
49
47
|
* [Quiet Assets](https://github.com/evrone/quiet_assets) for muting the Rails asset pipeline log
|
50
48
|
* [Awesome Print](https://github.com/michaeldv/awesome_print) for pretty printing command line objects
|
51
49
|
|
52
|
-
|
50
|
+
##Testing
|
53
51
|
* [Minitest](https://github.com/blowmage/minitest-rails) for TDD/BDD
|
54
52
|
* [Minitest Reporters](https://github.com/kern/minitest-reporters) for customizable Minitest output formats
|
53
|
+
* [Minitest Around](https://github.com/splattael/minitest-around) for database setup/teardown
|
54
|
+
* [Mocha](https://github.com/freerange/mocha) for mocking and stubbing
|
55
|
+
* [Database Cleaner](https://github.com/DatabaseCleaner/database_cleaner) to ensure a clean state during tests
|
55
56
|
|
56
|
-
|
57
|
-
* [Sorcery](https://github.com/NoamB/sorcery) for user authentication
|
58
|
-
|
59
|
-
####API
|
57
|
+
##API
|
60
58
|
* [Jbuilder](https://github.com/rails/jbuilder) for building JSON structures
|
61
59
|
* [oj](https://github.com/ohler55/oj) for faster JSON parsing (and a faster Jbuilder)
|
62
60
|
* [oj_mimic_json](https://github.com/ohler55/oj_mimic_json)
|
63
61
|
* [MultiJSON](https://github.com/intridea/multi_json)
|
64
62
|
|
65
|
-
Design Patterns
|
66
|
-
---
|
63
|
+
##Design Patterns
|
67
64
|
* Services (Pre-made folder)
|
68
65
|
* [Custom Decorator Class](templates/barebones_decorator.rb.erb) (A custom subclass of SimpleDelegator)
|
69
66
|
|
70
|
-
API
|
71
|
-
|
72
|
-
* [Routes](templates/Gemfile.erb) with API subdomain and version namespacing
|
67
|
+
##API
|
68
|
+
* [Routes](templates/routes.rb.erb) with API subdomain and version namespacing
|
73
69
|
* [ApiConstraints](templates/api_constraints.rb.erb) for API version control
|
74
70
|
* [Configurations/Ping endpoint](templates/configs_controller.rb) to test that the API works :)
|
75
71
|
|
76
|
-
Dependencies
|
77
|
-
|
78
|
-
Barebones requires the latest version of Ruby (2.2.3), Rails (4.2.3), and
|
72
|
+
#Dependencies
|
73
|
+
Barebones requires the latest version of Ruby (2.3.0), Rails (4.2.5), and
|
79
74
|
PostgreSQL (9.4) on your local machine.
|
80
75
|
|
81
|
-
License
|
82
|
-
|
83
|
-
Barebones is copyright © 2015 Danny Yu.
|
76
|
+
#License
|
77
|
+
Barebones is copyright © 2015-2016 Danny Yu.
|
84
78
|
It is free software, and may be redistributed under the terms specified in the [LICENSE] file.
|
85
79
|
|
86
80
|
[LICENSE]: LICENSE
|
data/barebones.gemspec
CHANGED
@@ -3,11 +3,11 @@ require "date"
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "barebones"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.4.0"
|
7
7
|
s.date = Date.today.to_s
|
8
8
|
s.licenses = ['MIT']
|
9
9
|
s.summary = "Rails template generator"
|
10
|
-
s.description = "
|
10
|
+
s.description = "A personal Rails template generator."
|
11
11
|
s.authors = ["Danny Yu"]
|
12
12
|
s.files = `git ls-files -z`.split("\x0")
|
13
13
|
s.executables = ["barebones"]
|
@@ -26,20 +26,7 @@ module Barebones
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def config
|
29
|
-
|
30
|
-
|
31
|
-
inside "config" do
|
32
|
-
customize_routes
|
33
|
-
template "application.rb"
|
34
|
-
customize_application_rb
|
35
|
-
|
36
|
-
template "environment.rb"
|
37
|
-
|
38
|
-
directory "environments"
|
39
|
-
directory "initializers"
|
40
|
-
directory "locales"
|
41
|
-
end
|
42
|
-
|
29
|
+
super
|
43
30
|
end
|
44
31
|
|
45
32
|
def database_yml
|
@@ -51,16 +38,17 @@ module Barebones
|
|
51
38
|
create_file ".ruby-version", "#{Barebones::RUBY_VERSION}"
|
52
39
|
end
|
53
40
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
41
|
+
def setup_autoload_paths
|
42
|
+
application_class_end_line = "#{spaces(2)}end\nend"
|
43
|
+
inject_into_file "config/application.rb",
|
44
|
+
before: application_class_end_line do
|
57
45
|
"\n#{spaces(4)}# Autoload 'lib' folder\n"\
|
58
|
-
"#{spaces(4)}config.autoload_paths
|
46
|
+
"#{spaces(4)}config.autoload_paths += Dir[\"\#{config.root}/lib/**/\"]\n"
|
59
47
|
end
|
60
48
|
end
|
61
49
|
|
62
50
|
def customize_routes
|
63
|
-
template "routes.rb", "config/routes.rb"
|
51
|
+
template "routes.rb.erb", "config/routes.rb", force: true
|
64
52
|
end
|
65
53
|
|
66
54
|
def setup_oj
|
@@ -93,7 +81,7 @@ module Barebones
|
|
93
81
|
end
|
94
82
|
|
95
83
|
def customize_secrets
|
96
|
-
template "secrets.yml.erb", "config/secrets.yml"
|
84
|
+
template "secrets.yml.erb", "config/secrets.yml", force: true
|
97
85
|
end
|
98
86
|
|
99
87
|
def raise_on_delivery_errors
|
@@ -108,21 +96,62 @@ module Barebones
|
|
108
96
|
run "cp #{environment_path}/development.rb #{environment_path}/staging.rb"
|
109
97
|
end
|
110
98
|
|
99
|
+
def configure_factory_girl
|
100
|
+
application_class_end_line = "#{spaces(2)}end\nend"
|
101
|
+
inject_into_file "config/application.rb",
|
102
|
+
before: application_class_end_line do
|
103
|
+
"\n#{spaces(4)}# Generate Factories instead of Fixtures\n"\
|
104
|
+
"#{spaces(4)}config.generators do |g|\n"\
|
105
|
+
"#{spaces(6)}g.factory_girl true\n"\
|
106
|
+
"#{spaces(4)}end\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
class_end_line = "end\n"
|
110
|
+
inject_into_file "test/test_helper.rb",
|
111
|
+
after: class_end_line do
|
112
|
+
"# Minitest does not provide a way to include or "\
|
113
|
+
"extend a module into every test class\n"\
|
114
|
+
"# without re-opening the test case class\n"\
|
115
|
+
"module Minitest\n"\
|
116
|
+
"#{spaces(2)}class Test\n"\
|
117
|
+
"#{spaces(4)}include FactoryGirl::Syntax::Methods\n"\
|
118
|
+
"#{spaces(2)}end\n"\
|
119
|
+
"end\n"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
111
123
|
def configure_minitest
|
112
|
-
|
124
|
+
class_end_line = "#{spaces(2)}end\nend"
|
113
125
|
inject_into_file "config/application.rb",
|
114
|
-
|
126
|
+
before: class_end_line do
|
115
127
|
"\n#{spaces(4)}# Auto generate test files\n"\
|
116
128
|
"#{spaces(4)}config.generators do |g|\n"\
|
117
|
-
"#{spaces(6)}g.test_framework :minitest, spec:
|
129
|
+
"#{spaces(6)}g.test_framework :minitest, spec: true, fixture: false\n"\
|
118
130
|
"#{spaces(4)}end\n"
|
119
131
|
end
|
132
|
+
|
133
|
+
last_require = "require 'rails/test_help'\n"
|
134
|
+
inject_into_file "test/test_helper.rb",
|
135
|
+
after: last_require do
|
136
|
+
"require 'minitest/reporters'\n"\
|
137
|
+
"require 'minitest/spec'\n"\
|
138
|
+
"require 'mocha/mini_test'\n"\
|
139
|
+
"# Require all support helpers\n"\
|
140
|
+
"Dir[Rails.root.join('test/support/**/*.rb')].each { |f| require f }\n"\
|
141
|
+
"\n"\
|
142
|
+
"Minitest::Reporters.use!(\n"\
|
143
|
+
"#{spaces(2)}Minitest::Reporters::DefaultReporter.new,\n"\
|
144
|
+
"#{spaces(2)}ENV,\n"\
|
145
|
+
"#{spaces(2)}Minitest.backtrace_filter\n"\
|
146
|
+
")\n"
|
147
|
+
end
|
148
|
+
|
120
149
|
end
|
121
150
|
|
122
151
|
def configure_active_job
|
123
|
-
|
152
|
+
application_class_end_line = "#{spaces(2)}end\nend"
|
124
153
|
inject_into_file "config/application.rb",
|
125
|
-
|
154
|
+
before: application_class_end_line do
|
126
155
|
"\n#{spaces(4)}# Set ActiveJob to use Resque\n"\
|
127
156
|
"#{spaces(4)}config.active_job.queue_adapter = :resque\n"
|
128
157
|
end
|
@@ -12,18 +12,20 @@ module Barebones
|
|
12
12
|
class_option :skip_resque, type: :boolean, default: false,
|
13
13
|
desc: "Skip using Resque. Default is false."
|
14
14
|
|
15
|
-
class_option :skip_sorcery, type: :boolean, default: false,
|
16
|
-
desc: "Skip using Sorcery for user authentication. Default is false."
|
17
|
-
|
18
15
|
class_option :skip_minitest, type: :boolean, default: false,
|
19
16
|
desc: "Skip using Minitest. Default is false."
|
20
17
|
|
18
|
+
class_option :skip_factory_girl, type: :boolean, default: false,
|
19
|
+
desc: "Skip using Factory Girl. Default is false."
|
20
|
+
|
21
21
|
class_option :skip_carrierwave, type: :boolean, default: false,
|
22
22
|
desc: "Skip using Carrierwave. Default is false."
|
23
23
|
|
24
24
|
def customizations
|
25
25
|
say "Invoking customizations..."
|
26
26
|
invoke :setup_ruby
|
27
|
+
invoke :configure_app
|
28
|
+
invoke :setup_routes
|
27
29
|
invoke :setup_api
|
28
30
|
invoke :setup_secrets
|
29
31
|
invoke :setup_environments
|
@@ -36,10 +38,19 @@ module Barebones
|
|
36
38
|
build :set_ruby_version
|
37
39
|
end
|
38
40
|
|
41
|
+
def setup_routes
|
42
|
+
say "Setting up custom routes..."
|
43
|
+
build :customize_routes
|
44
|
+
end
|
45
|
+
|
46
|
+
def configure_app
|
47
|
+
say "Configuring application..."
|
48
|
+
build :setup_autoload_paths
|
49
|
+
end
|
50
|
+
|
39
51
|
def setup_api
|
40
52
|
unless options[:skip_api]
|
41
53
|
say "Setting up an API..."
|
42
|
-
build :customize_routes
|
43
54
|
build :setup_oj
|
44
55
|
build :create_api_constraints
|
45
56
|
build :create_api_v1_defaults
|
@@ -73,11 +84,18 @@ module Barebones
|
|
73
84
|
|
74
85
|
def setup_gems
|
75
86
|
invoke :setup_minitest
|
76
|
-
|
87
|
+
invoke :setup_factory_girl
|
77
88
|
invoke :setup_resque
|
78
89
|
invoke :setup_carrierwave
|
79
90
|
end
|
80
91
|
|
92
|
+
def setup_factory_girl
|
93
|
+
unless options[:skip_factory_girl]
|
94
|
+
say "Setting up FactoryGirl gem..."
|
95
|
+
build :configure_factory_girl
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
81
99
|
def setup_minitest
|
82
100
|
unless options[:skip_minitest]
|
83
101
|
say "Setting up Minitest gem..."
|
@@ -104,33 +122,11 @@ module Barebones
|
|
104
122
|
end
|
105
123
|
|
106
124
|
def outro
|
107
|
-
invoke :minitest_setup_reminder
|
108
|
-
invoke :resque_web_reminder
|
109
125
|
say "\e[34mSweet, we're done!\e[0m"
|
110
126
|
end
|
111
127
|
|
112
|
-
def minitest_setup_reminder
|
113
|
-
unless options[:skip_minitest]
|
114
|
-
say "==========================================\n"\
|
115
|
-
"Remember to run `rails g minitest:install` \n"\
|
116
|
-
"and to set up Minitest-Reporters!\n"\
|
117
|
-
"==========================================\n"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def resque_web_reminder
|
122
|
-
unless options[:skip_resque]
|
123
|
-
say "==============================================\n"\
|
124
|
-
"If you'd like to have the resque-web dashboard, \n"\
|
125
|
-
"you should add the following to your routes: \n"\
|
126
|
-
"`require 'resque/scheduler/server'`\n"\
|
127
|
-
"`mount Resque::Server.new, :at => '/resque'`\n"\
|
128
|
-
"==============================================\n"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
128
|
protected
|
133
|
-
|
129
|
+
|
134
130
|
# Supply Thor with template root path
|
135
131
|
def self.source_root
|
136
132
|
File.expand_path("../../../templates", File.dirname(__FILE__))
|
data/lib/barebones/version.rb
CHANGED
data/templates/Gemfile.erb
CHANGED
@@ -20,6 +20,12 @@ group :development, :test do
|
|
20
20
|
<% unless options[:skip_minitest] %>
|
21
21
|
gem "minitest-rails"
|
22
22
|
gem "minitest-reporters"
|
23
|
+
gem "minitest-around"
|
24
|
+
gem "mocha"
|
25
|
+
gem "database_cleaner"
|
26
|
+
<% end %>
|
27
|
+
<% unless options[:skip_factory_girl] %>
|
28
|
+
gem "factory_girl_rails", "~> 4.0"
|
23
29
|
<% end %>
|
24
30
|
end
|
25
31
|
|
@@ -37,12 +43,7 @@ gem "resque-scheduler"
|
|
37
43
|
<% end %>
|
38
44
|
|
39
45
|
# Database
|
40
|
-
gem "pg", "~> 0.18.
|
41
|
-
|
42
|
-
<% unless options[:skip_sorcery] %>
|
43
|
-
# Authentication
|
44
|
-
gem "sorcery"
|
45
|
-
<% end %>
|
46
|
+
gem "pg", "~> 0.18.4"
|
46
47
|
|
47
48
|
# Faster JSON Parsing
|
48
49
|
gem "oj"
|
@@ -7,20 +7,20 @@ module ApiDefaults
|
|
7
7
|
API_DEFAULT_FAIL_PATH = "defaults/fail"
|
8
8
|
|
9
9
|
# Statuses
|
10
|
-
|
11
|
-
|
10
|
+
SUCCESS = 200
|
11
|
+
INTERNAL_SERVER_ERROR = 500
|
12
12
|
|
13
13
|
included do
|
14
14
|
layout 'api/v1/application'
|
15
15
|
|
16
16
|
def render_api_success(path=ApiDefaults::API_DEFAULT_SUCCESS_PATH)
|
17
|
-
@status = ApiDefaults::
|
18
|
-
return render template: "#{API_VIEW_PATH}/#{path}"
|
17
|
+
@status = ApiDefaults::SUCCESS
|
18
|
+
return render template: "#{API_VIEW_PATH}/#{path}", status: ApiDefaults::SUCCESS
|
19
19
|
end
|
20
20
|
|
21
21
|
def render_api_fail(path=ApiDefaults::API_DEFAULT_FAIL_PATH)
|
22
|
-
@status = ApiDefaults::
|
23
|
-
return render template: "#{API_VIEW_PATH}/#{path}"
|
22
|
+
@status = ApiDefaults::INTERNAL_SERVER_ERROR
|
23
|
+
return render template: "#{API_VIEW_PATH}/#{path}", status: ApiDefaults::INTERNAL_SERVER_ERROR
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barebones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Yu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,15 +16,15 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.
|
19
|
+
version: 4.2.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.2.
|
27
|
-
description:
|
26
|
+
version: 4.2.5
|
27
|
+
description: A personal Rails template generator.
|
28
28
|
email:
|
29
29
|
executables:
|
30
30
|
- barebones
|
@@ -57,7 +57,7 @@ files:
|
|
57
57
|
- templates/redis.rb
|
58
58
|
- templates/resque.rake
|
59
59
|
- templates/resque.rb
|
60
|
-
- templates/routes.rb
|
60
|
+
- templates/routes.rb.erb
|
61
61
|
- templates/secrets.yml.erb
|
62
62
|
- templates/test_job.rb
|
63
63
|
homepage: https://github.com/dannyyu92/barebones
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.4.
|
83
|
+
rubygems_version: 2.4.8
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Rails template generator
|