potassium 2.3.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +19 -2
- data/bin/potassium_test +6 -0
- data/lib/potassium/assets/README.yml +4 -1
- data/lib/potassium/assets/api/draper_responder.rb +62 -0
- data/lib/potassium/assets/bin/setup.erb +1 -1
- data/lib/potassium/cli/commands/create.rb +5 -58
- data/lib/potassium/cli.rb +1 -3
- data/lib/potassium/cli_options.rb +151 -0
- data/lib/potassium/helpers/rubocop-helpers.rb +15 -0
- data/lib/potassium/helpers/template-dsl.rb +2 -0
- data/lib/potassium/recipes/aws_sdk.rb +1 -1
- data/lib/potassium/recipes/better_errors.rb +8 -0
- data/lib/potassium/recipes/delayed_job.rb +1 -1
- data/lib/potassium/recipes/draper.rb +35 -0
- data/lib/potassium/recipes/github.rb +3 -1
- data/lib/potassium/recipes/i18n.rb +2 -2
- data/lib/potassium/recipes/mailer.rb +1 -1
- data/lib/potassium/recipes/paperclip.rb +1 -1
- data/lib/potassium/recipes/puma.rb +1 -3
- data/lib/potassium/recipes/rack_cors.rb +1 -1
- data/lib/potassium/templates/application.rb +9 -2
- data/lib/potassium/test_cli.rb +33 -0
- data/lib/potassium/version.rb +2 -2
- data/spec/features/draper_spec.rb +29 -0
- data/spec/support/potassium_test_helpers.rb +8 -21
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c4a19d0503fea30781bf341b2b73f8356e9ad07
|
4
|
+
data.tar.gz: 9de9d7b253c62e7d3c5486204c7a408f4375bc5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09d2f6e7342f589e44d54981dd093cd89a3998ef39007e326be9653509fe637cce0e255ffeffea5b6229a7b7416e948b52de17d6888d96125ef507c22a4ba19
|
7
|
+
data.tar.gz: db39d009346a0d435f9d6f316205ef9d5e0670637188a92695e2dc33bc0c78ce232236e8e24fa50f9ed52d854e9dc2af32db0b8c45b9cb287dda85d3f1a642fd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 3.0.0
|
6
|
+
|
7
|
+
Features:
|
8
|
+
- Rails 5.0.2
|
9
|
+
- `better_errors` and `binding_of_caller` gem in development
|
10
|
+
- Update `aws_sdk` to `~> 2.5`
|
11
|
+
- Update `paperclip` to `~> 5,0`
|
12
|
+
- Add draper gem to decorate models
|
13
|
+
|
5
14
|
## 2.3.0
|
6
15
|
|
7
16
|
Features:
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ The following optional integrations are added too:
|
|
59
59
|
- [ActiveAdminAddons](https://github.com/platanus/activeadmin_addons) for some help with ActiveAdmin.
|
60
60
|
- [Pundit](https://github.com/elabs/pundit) for role-based authorization.
|
61
61
|
- [DelayedJob](https://github.com/collectiveidea/delayed_job) to execute longer tasks in the background.]
|
62
|
-
- Mailing configuration for [AWS SES](https://github.com/aws/aws-sdk-rails)
|
62
|
+
- Mailing configuration for [AWS SES](https://github.com/aws/aws-sdk-rails)
|
63
63
|
and [Sendgrid](https://github.com/platanus/send_grid_mailer) with recipient interceptor support
|
64
64
|
- [Clockwork](https://github.com/Rykian/clockwork) to run scheduled processes
|
65
65
|
- [Sentry](https://sentry.io) to monitor exceptions and errors
|
@@ -71,7 +71,7 @@ A few more things are added to the project:
|
|
71
71
|
- Create the github repository for the project (it used `hub` under the hood)
|
72
72
|
- A `bin/setup` script to setup things on a newly cloned project
|
73
73
|
- A `bin/cibuild` script to run continuous integration build on CI
|
74
|
-
- A `db:fake_data:load` rake task to load fake data for development
|
74
|
+
- A `db:fake_data:load` rake task to load fake data for development
|
75
75
|
|
76
76
|
[pool]: https://devcenter.heroku.com/articles/concurrency-and-database-connections
|
77
77
|
|
@@ -141,6 +141,23 @@ Go to https://monkeyci.platan.us, choose the repository from the list and hit
|
|
141
141
|
[buildpack-deploy-tasks]: http://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
|
142
142
|
[circle-ci]: https://circleci.com
|
143
143
|
|
144
|
+
## Development Tools
|
145
|
+
|
146
|
+
### Creating a new **Test** project from scratch
|
147
|
+
|
148
|
+
This is useful when you are adding new recipes to Potassium, and you want to use the `potassium create` command, to check the new functionality without pain.
|
149
|
+
To achieve this you need to run, **In the Potassium's root path**, the `bin/potassium_test create` instead of `potassium create` command.
|
150
|
+
This command, will do the same as `potassium create` but first:
|
151
|
+
|
152
|
+
- Will drop any existent database of the test app.
|
153
|
+
- Will remove the directory containing a previous version of the test app.
|
154
|
+
|
155
|
+
It's important to remember that `bin/potassium_test create`:
|
156
|
+
|
157
|
+
- Does not receive an `app_path` param. It always creates the test project inside `/tmp/dummy_app`
|
158
|
+
- Can receive the same options as `potassium create`.
|
159
|
+
- Runs with options with a default value. This is to avoid the "asking part" of the creation process. You need to enable what you want to test like this: `$ bin/potassium_test create --clockwork`
|
160
|
+
|
144
161
|
## Contributing
|
145
162
|
|
146
163
|
If you want to add functionality please go to
|
data/bin/potassium_test
ADDED
@@ -62,7 +62,7 @@ readme:
|
|
62
62
|
style_guide:
|
63
63
|
title: "Style Guides"
|
64
64
|
body: |
|
65
|
-
The style guides are enforced through a self hosted version of [Hound CI](http://
|
65
|
+
The style guides are enforced through a self hosted version of [Hound CI](http://monkeyci.platan.us). The style configuration can also be used locally
|
66
66
|
in development runing `rubocop` or just using the rubocop integration for your text editor of choice.
|
67
67
|
|
68
68
|
You can add custom rules to this project just adding them to the `.ruby-style.yml` file.
|
@@ -98,6 +98,9 @@ readme:
|
|
98
98
|
sentry:
|
99
99
|
title: "Error Reporting"
|
100
100
|
body: "To report our errors we use [Sentry](https://github.com/getsentry/raven-ruby)"
|
101
|
+
draper:
|
102
|
+
title: "Presentation Layer"
|
103
|
+
body: "This project uses [Draper](https://github.com/drapergem/draper) to add an object-oriented layer of presentation logic"
|
101
104
|
seeds:
|
102
105
|
title: "Seeds"
|
103
106
|
body: |
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class ApiResponder < ActionController::Responder
|
2
|
+
def respond
|
3
|
+
return display_errors if has_errors?
|
4
|
+
return head :no_content if delete?
|
5
|
+
|
6
|
+
display resource, status_code: status_code
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def display(_resource, given_options = {})
|
12
|
+
controller.render options.merge(given_options).merge(
|
13
|
+
json: serializer.as_json
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def serializer
|
18
|
+
serializer_class = ActiveModel::Serializer.serializer_for(resource)
|
19
|
+
if serializer_class.present?
|
20
|
+
serializer_options = infer_serializer(serializer_class).merge(options)
|
21
|
+
serializer_class.new(decorated_resource, serializer_options)
|
22
|
+
else
|
23
|
+
decorated_resource
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def status_code
|
28
|
+
return :created if post?
|
29
|
+
:ok
|
30
|
+
end
|
31
|
+
|
32
|
+
def display_errors
|
33
|
+
controller.render(
|
34
|
+
status: :unprocessable_entity,
|
35
|
+
json: { msg: "invalid_attributes", errors: format_errors }
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def format_errors
|
40
|
+
resource.errors.as_json
|
41
|
+
end
|
42
|
+
|
43
|
+
def infer_serializer(serializer_class)
|
44
|
+
if serializer_class == ActiveModel::ArraySerializer
|
45
|
+
s = options.delete(:each_serializer) || "#{resource.klass}Serializer".constantize
|
46
|
+
{ each_serializer: s }
|
47
|
+
else
|
48
|
+
s = options.delete(:serializer) || "#{resource.class}Serializer".constantize
|
49
|
+
{ serializer: s }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def decorated_resource
|
54
|
+
if resource.respond_to?(:decorate)
|
55
|
+
resource.decorate
|
56
|
+
else
|
57
|
+
resource
|
58
|
+
end
|
59
|
+
rescue Draper::UninferrableDecoratorError
|
60
|
+
resource
|
61
|
+
end
|
62
|
+
end
|
@@ -1,4 +1,8 @@
|
|
1
|
+
require 'potassium/cli_options'
|
2
|
+
|
1
3
|
module Potassium::CLI
|
4
|
+
extend Potassium::CliOptions
|
5
|
+
|
2
6
|
desc "Create a new Potassium Rails project."
|
3
7
|
arg 'app_path'
|
4
8
|
command :create do |c|
|
@@ -8,64 +12,7 @@ module Potassium::CLI
|
|
8
12
|
desc: "Performs a version check before running.",
|
9
13
|
negatable: true
|
10
14
|
|
11
|
-
c.
|
12
|
-
desc: "Decides which database to use. Available: mysql, postgresql, none"
|
13
|
-
c.flag "locale",
|
14
|
-
desc: "Decides which locale to use. Available: es-CL, en"
|
15
|
-
c.flag [:email_service, :email],
|
16
|
-
desc: "Decides which email adapter to use. Available: aws_ses, sendgrid, none"
|
17
|
-
c.switch "devise",
|
18
|
-
desc: "Whether to use Devise for authentication or not",
|
19
|
-
negatable: true,
|
20
|
-
default_value: "none"
|
21
|
-
c.switch "devise-user-model",
|
22
|
-
desc: "Whether to create a User model for Devise",
|
23
|
-
negatable: true,
|
24
|
-
default_value: "none"
|
25
|
-
c.switch "admin",
|
26
|
-
desc: "Whether to use ActiveAdmin or not",
|
27
|
-
negatable: true,
|
28
|
-
default_value: "none"
|
29
|
-
c.switch "angular-admin",
|
30
|
-
desc: "Whether to use Angular within ActiveAdmin or not",
|
31
|
-
negatable: true,
|
32
|
-
default_value: "none"
|
33
|
-
c.switch "pundit",
|
34
|
-
desc: "Whether to use Pundit for authorization or not",
|
35
|
-
negatable: true,
|
36
|
-
default_value: "none"
|
37
|
-
c.switch "api",
|
38
|
-
desc: "Whether to apply the API mode or not",
|
39
|
-
negatable: true,
|
40
|
-
default_value: "none"
|
41
|
-
c.switch "paperclip",
|
42
|
-
desc: "Whether to include Paperclip as dependency",
|
43
|
-
negatable: true,
|
44
|
-
default_value: "none"
|
45
|
-
c.switch "heroku",
|
46
|
-
desc: "Whether to prepare to application for Heroku or not",
|
47
|
-
negatable: true,
|
48
|
-
default_value: "none"
|
49
|
-
c.switch "delayed-job",
|
50
|
-
desc: "Whether to use DelayedJob or not",
|
51
|
-
negatable: true,
|
52
|
-
default_value: "none"
|
53
|
-
c.switch "github",
|
54
|
-
desc: "Whether to create a github repository",
|
55
|
-
negatable: true,
|
56
|
-
default_value: "none"
|
57
|
-
c.switch "github-private",
|
58
|
-
desc: "Whether to the github repository is private",
|
59
|
-
negatable: true,
|
60
|
-
default_value: false
|
61
|
-
c.switch "clockwork",
|
62
|
-
desc: "Whether to use clockwork as job scheduler",
|
63
|
-
negatable: true,
|
64
|
-
default_value: "none"
|
65
|
-
c.switch "sentry",
|
66
|
-
desc: "Whether to use Sentry as error reporting tool",
|
67
|
-
negatable: true,
|
68
|
-
default_value: "none"
|
15
|
+
create_options.each { |opts| c.send(opts.delete(:type), opts.delete(:name), opts) }
|
69
16
|
|
70
17
|
c.action do |_global_options, options, _args|
|
71
18
|
require "potassium/newest_version_ensurer"
|
data/lib/potassium/cli.rb
CHANGED
@@ -4,11 +4,9 @@ require "gli"
|
|
4
4
|
module Potassium::CLI
|
5
5
|
extend GLI::App
|
6
6
|
|
7
|
-
program_desc "
|
8
|
-
|
7
|
+
program_desc "Platanus Rails application generator"
|
9
8
|
version Potassium::VERSION
|
10
9
|
hide_commands_without_desc true
|
11
|
-
|
12
10
|
commands_from "potassium/cli/commands"
|
13
11
|
|
14
12
|
exit Potassium::CLI.run(ARGV)
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
|
2
|
+
CREATE_OPTIONS = [
|
3
|
+
{
|
4
|
+
type: :flag,
|
5
|
+
name: [:db, :database],
|
6
|
+
desc: "Decides which database to use. Available: mysql, postgresql, none",
|
7
|
+
default_test_value: "postgresql"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
type: :flag,
|
11
|
+
name: "locale",
|
12
|
+
desc: "Decides which locale to use. Available: es-CL, en",
|
13
|
+
default_test_value: "es-CL"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
type: :flag,
|
17
|
+
name: [:email_service, :email],
|
18
|
+
desc: "Decides which email adapter to use. Available: aws_ses, sendgrid, none",
|
19
|
+
default_test_value: "aws_ses"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
type: :switch,
|
23
|
+
name: "devise",
|
24
|
+
desc: "Whether to use Devise for authentication or not",
|
25
|
+
negatable: true,
|
26
|
+
default_value: "none",
|
27
|
+
default_test_value: false
|
28
|
+
},
|
29
|
+
{
|
30
|
+
type: :switch,
|
31
|
+
name: "devise-user-model",
|
32
|
+
desc: "Whether to create a User model for Devise",
|
33
|
+
negatable: true,
|
34
|
+
default_value: "none",
|
35
|
+
default_test_value: false
|
36
|
+
},
|
37
|
+
{
|
38
|
+
type: :switch,
|
39
|
+
name: "admin",
|
40
|
+
desc: "Whether to use ActiveAdmin or not",
|
41
|
+
negatable: true,
|
42
|
+
default_value: "none",
|
43
|
+
default_test_value: false
|
44
|
+
},
|
45
|
+
{
|
46
|
+
type: :switch,
|
47
|
+
name: "angular-admin",
|
48
|
+
desc: "Whether to use Angular within ActiveAdmin or not",
|
49
|
+
negatable: true,
|
50
|
+
default_value: "none",
|
51
|
+
default_test_value: false
|
52
|
+
},
|
53
|
+
{
|
54
|
+
type: :switch,
|
55
|
+
name: "pundit",
|
56
|
+
desc: "Whether to use Pundit for authorization or not",
|
57
|
+
negatable: true,
|
58
|
+
default_value: "none",
|
59
|
+
default_test_value: false
|
60
|
+
},
|
61
|
+
{
|
62
|
+
type: :switch,
|
63
|
+
name: "api",
|
64
|
+
desc: "Whether to apply the API mode or not",
|
65
|
+
negatable: true,
|
66
|
+
default_value: "none",
|
67
|
+
default_test_value: false
|
68
|
+
},
|
69
|
+
{
|
70
|
+
type: :switch,
|
71
|
+
name: "paperclip",
|
72
|
+
desc: "Whether to include Paperclip as dependency",
|
73
|
+
negatable: true,
|
74
|
+
default_value: "none",
|
75
|
+
default_test_value: false
|
76
|
+
},
|
77
|
+
{
|
78
|
+
type: :switch,
|
79
|
+
name: "heroku",
|
80
|
+
desc: "Whether to prepare to application for Heroku or not",
|
81
|
+
negatable: true,
|
82
|
+
default_value: "none",
|
83
|
+
default_test_value: false
|
84
|
+
},
|
85
|
+
{
|
86
|
+
type: :switch,
|
87
|
+
name: "delayed-job",
|
88
|
+
desc: "Whether to use DelayedJob or not",
|
89
|
+
negatable: true,
|
90
|
+
default_value: "none",
|
91
|
+
default_test_value: false
|
92
|
+
},
|
93
|
+
{
|
94
|
+
type: :switch,
|
95
|
+
name: "draper",
|
96
|
+
desc: "Whether to use Draper or not",
|
97
|
+
negatable: true,
|
98
|
+
default_value: "none",
|
99
|
+
default_test_value: false
|
100
|
+
},
|
101
|
+
{
|
102
|
+
type: :switch,
|
103
|
+
name: "github",
|
104
|
+
desc: "Whether to create a github repository",
|
105
|
+
negatable: true,
|
106
|
+
default_value: "none",
|
107
|
+
default_test_value: false
|
108
|
+
},
|
109
|
+
{
|
110
|
+
type: :switch,
|
111
|
+
name: "github-private",
|
112
|
+
desc: "Whether to the github repository is private",
|
113
|
+
negatable: true,
|
114
|
+
default_value: false,
|
115
|
+
default_test_value: false
|
116
|
+
},
|
117
|
+
{
|
118
|
+
type: :switch,
|
119
|
+
name: "clockwork",
|
120
|
+
desc: "Whether to use clockwork as job scheduler",
|
121
|
+
negatable: true,
|
122
|
+
default_value: "none",
|
123
|
+
default_test_value: false
|
124
|
+
},
|
125
|
+
{
|
126
|
+
type: :switch,
|
127
|
+
name: "sentry",
|
128
|
+
desc: "Whether to use Sentry as error reporting tool",
|
129
|
+
negatable: true,
|
130
|
+
default_value: "none",
|
131
|
+
default_test_value: false
|
132
|
+
}
|
133
|
+
]
|
134
|
+
|
135
|
+
def create_options(test_env = false)
|
136
|
+
CREATE_OPTIONS.map do |opts|
|
137
|
+
opts = opts.dup
|
138
|
+
test_default_value = opts.delete(:default_test_value)
|
139
|
+
opts[:default_value] = test_default_value if test_env
|
140
|
+
opts
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_arguments(test_env = false)
|
145
|
+
create_options(test_env).inject({}) do |memo, opts|
|
146
|
+
opt = opts[:name].is_a?(Array) ? opts[:name].first : opts[:name]
|
147
|
+
memo[opt.to_s] = opts[:default_value]
|
148
|
+
memo
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RubocopHelpers
|
2
|
+
def rubocop_revision
|
3
|
+
fix_environments
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def fix_environments
|
9
|
+
# Style problem in Rails 5 production environments
|
10
|
+
file_name = "config/environments/production.rb"
|
11
|
+
production = File.read(file_name)
|
12
|
+
production.gsub!("config.log_tags = [ :request_id ]", "config.log_tags = [:request_id]")
|
13
|
+
File.open(file_name, "w") { |file| file.write(production) }
|
14
|
+
end
|
15
|
+
end
|
@@ -9,6 +9,7 @@ module TemplateDSL
|
|
9
9
|
require_relative './answer-helpers'
|
10
10
|
require_relative './info-helpers'
|
11
11
|
require_relative './readme-helpers'
|
12
|
+
require_relative './rubocop-helpers'
|
12
13
|
|
13
14
|
object.send :extend, TemplateHelpers
|
14
15
|
object.send :extend, VariableHelpers
|
@@ -18,6 +19,7 @@ module TemplateDSL
|
|
18
19
|
object.send :extend, AnswerHelpers
|
19
20
|
object.send :extend, InfoHelpers
|
20
21
|
object.send :extend, ReadmeHelpers
|
22
|
+
object.send :extend, RubocopHelpers
|
21
23
|
|
22
24
|
object.send :source_path, source_path
|
23
25
|
object.load_answers
|
@@ -31,7 +31,7 @@ class Recipes::DelayedJob < Rails::AppBuilder
|
|
31
31
|
add_readme_section :internal_dependencies, :delayed_job
|
32
32
|
|
33
33
|
if selected?(:heroku)
|
34
|
-
gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: bundle exec
|
34
|
+
gsub_file("Procfile", /^.*$/m) { |match| "#{match}worker: bundle exec rails jobs:work" }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Recipes::Draper < Rails::AppBuilder
|
2
|
+
def ask
|
3
|
+
draper = answer(:draper) { Ask.confirm('Do you want to use Draper to decorate models?') }
|
4
|
+
set(:draper, draper)
|
5
|
+
end
|
6
|
+
|
7
|
+
def create
|
8
|
+
return unless selected?(:draper)
|
9
|
+
add_draper
|
10
|
+
add_api_responder if selected?(:api_support)
|
11
|
+
end
|
12
|
+
|
13
|
+
def installed?
|
14
|
+
gem_exists?(/draper/)
|
15
|
+
end
|
16
|
+
|
17
|
+
def install
|
18
|
+
add_draper
|
19
|
+
api_recipe = load_recipe(:api)
|
20
|
+
add_api_responder if api_recipe.installed?
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_draper
|
24
|
+
gather_gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
|
25
|
+
gather_gem 'draper'
|
26
|
+
add_readme_section :internal_dependencies, :draper
|
27
|
+
create_file 'app/decorators/.keep'
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_api_responder
|
31
|
+
after(:gem_install) do
|
32
|
+
copy_file '../assets/api/draper_responder.rb', 'app/responders/api_responder.rb', force: true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -2,7 +2,9 @@ class Recipes::Github < Rails::AppBuilder
|
|
2
2
|
def ask
|
3
3
|
repo_name = "platanus/#{get(:dasherized_app_name)}"
|
4
4
|
github_repo_create = answer(:github) do
|
5
|
-
|
5
|
+
q = "Do you want to create the Github repository (https://github.com/#{repo_name}) " +
|
6
|
+
"for this project?"
|
7
|
+
Ask.confirm(q)
|
6
8
|
end
|
7
9
|
if github_repo_create
|
8
10
|
github_repo_private = answer(:"github-private") do
|
@@ -19,8 +19,8 @@ class Recipes::I18n < Rails::AppBuilder
|
|
19
19
|
template('../assets/es-CL.yml', 'config/locales/es-CL.yml')
|
20
20
|
end
|
21
21
|
|
22
|
-
gsub_file 'config/application.rb',
|
23
|
-
"config.i18n.default_locale = '#{get(:lang)}'\n config.i18n.fallbacks = [:es, :en]\n"
|
22
|
+
gsub_file 'config/application.rb', /< Rails::Application/ do
|
23
|
+
"< Rails::Application\n config.i18n.default_locale = '#{get(:lang)}'\n config.i18n.fallbacks = [:es, :en]\n"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -74,7 +74,7 @@ class Recipes::Mailer < Rails::AppBuilder
|
|
74
74
|
RUBY
|
75
75
|
|
76
76
|
prepend_file "config/environments/production.rb", mailer_config
|
77
|
-
copy_file '../assets/app/mailers/application_mailer.rb', 'app/mailers/application_mailer.rb'
|
77
|
+
copy_file '../assets/app/mailers/application_mailer.rb', 'app/mailers/application_mailer.rb', force: true
|
78
78
|
|
79
79
|
send(service[:name])
|
80
80
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
class Recipes::Puma < Rails::AppBuilder
|
2
2
|
def create
|
3
|
-
gather_gem 'puma'
|
4
|
-
|
5
3
|
gather_gems(:production) do
|
6
4
|
gather_gem 'rack-timeout'
|
7
5
|
end
|
8
6
|
|
9
|
-
copy_file '../assets/config/puma.rb', 'config/puma.rb'
|
7
|
+
copy_file '../assets/config/puma.rb', 'config/puma.rb', force: true
|
10
8
|
|
11
9
|
# Configure rack-timout
|
12
10
|
rack_timeout_config =
|
@@ -3,6 +3,10 @@ set :titleized_app_name, get(:app_name).titleize
|
|
3
3
|
set :underscorized_app_name, get(:app_name).underscore
|
4
4
|
set :dasherized_app_name, get(:app_name).dasherize
|
5
5
|
|
6
|
+
run_action(:after_create_rails) do
|
7
|
+
rubocop_revision
|
8
|
+
end
|
9
|
+
|
6
10
|
run_action(:cleaning) do
|
7
11
|
clean_gemfile
|
8
12
|
gather_gem("spring")
|
@@ -19,6 +23,7 @@ run_action(:asking) do
|
|
19
23
|
ask :pundit
|
20
24
|
ask :i18n
|
21
25
|
ask :api
|
26
|
+
ask :draper
|
22
27
|
ask :paperclip
|
23
28
|
ask :mailer
|
24
29
|
ask :heroku
|
@@ -42,6 +47,7 @@ run_action(:recipe_loading) do
|
|
42
47
|
create :mailer
|
43
48
|
create :i18n
|
44
49
|
create :pry
|
50
|
+
create :better_errors
|
45
51
|
create :devise
|
46
52
|
create :admin
|
47
53
|
create :angular_admin
|
@@ -53,6 +59,7 @@ run_action(:recipe_loading) do
|
|
53
59
|
create :secrets
|
54
60
|
create :git
|
55
61
|
create :api
|
62
|
+
create :draper
|
56
63
|
create :rack_cors
|
57
64
|
create :paperclip
|
58
65
|
create :tzinfo
|
@@ -69,6 +76,6 @@ run_action(:gem_install) do
|
|
69
76
|
end
|
70
77
|
|
71
78
|
run_action(:database_creation) do
|
72
|
-
run "bundle exec
|
73
|
-
run "RACK_ENV=test bundle exec
|
79
|
+
run "bundle exec rails db:create db:migrate"
|
80
|
+
run "RACK_ENV=test bundle exec rails db:create db:migrate"
|
74
81
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "potassium/version"
|
2
|
+
require 'potassium/cli_options'
|
3
|
+
require './spec/support/potassium_test_helpers'
|
4
|
+
require "term/ansicolor"
|
5
|
+
require "gli"
|
6
|
+
|
7
|
+
module Potassium::TestCLI
|
8
|
+
extend self
|
9
|
+
extend GLI::App
|
10
|
+
extend PotassiumTestHelpers
|
11
|
+
extend Potassium::CliOptions
|
12
|
+
extend Term::ANSIColor
|
13
|
+
|
14
|
+
program_desc "Platanus Rails TEST application generator"
|
15
|
+
version Potassium::VERSION
|
16
|
+
hide_commands_without_desc true
|
17
|
+
|
18
|
+
desc "Create a new Potassium TEST project"
|
19
|
+
command :create do |c|
|
20
|
+
c.default_desc "Create a TEST project"
|
21
|
+
|
22
|
+
create_options(true).each { |opts| c.send(opts.delete(:type), opts.delete(:name), opts) }
|
23
|
+
|
24
|
+
c.action do |_global_options, options, _args|
|
25
|
+
drop_dummy_database
|
26
|
+
remove_project_directory
|
27
|
+
create_dummy_project(options)
|
28
|
+
puts green("Your test app was created inside the #{project_path} directory")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
exit Potassium::TestCLI.run(ARGV)
|
33
|
+
end
|
data/lib/potassium/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Draper" do
|
4
|
+
before :all do
|
5
|
+
drop_dummy_database
|
6
|
+
remove_project_directory
|
7
|
+
create_dummy_project("draper" => true, "api" => true)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "adds the Draper gem to Gemfile" do
|
11
|
+
gemfile_content = IO.read("#{project_path}/Gemfile")
|
12
|
+
expect(gemfile_content).to include("gem 'draper'")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "adds the Draper brief to README file" do
|
16
|
+
readme = IO.read("#{project_path}/README.md")
|
17
|
+
expect(readme).to include("Draper")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "adds api responder to work with draper" do
|
21
|
+
responder_content = IO.read("#{project_path}/app/responders/api_responder.rb")
|
22
|
+
expect(responder_content).to include("decorated_resource")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "adds decorators directory" do
|
26
|
+
content = IO.read("#{project_path}/app/decorators/.keep")
|
27
|
+
expect(content).to be_empty
|
28
|
+
end
|
29
|
+
end
|
@@ -1,4 +1,10 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'bundler'
|
3
|
+
require 'potassium/cli_options'
|
4
|
+
|
1
5
|
module PotassiumTestHelpers
|
6
|
+
include Potassium::CliOptions
|
7
|
+
|
2
8
|
APP_NAME = "dummy_app"
|
3
9
|
|
4
10
|
def remove_project_directory
|
@@ -13,7 +19,7 @@ module PotassiumTestHelpers
|
|
13
19
|
Dir.chdir(tmp_path) do
|
14
20
|
Bundler.with_clean_env do
|
15
21
|
add_fakes_to_path
|
16
|
-
full_arguments = hash_to_arguments(
|
22
|
+
full_arguments = hash_to_arguments(create_arguments(true).merge(arguments))
|
17
23
|
run_command("#{potassium_bin} create #{APP_NAME} #{full_arguments}")
|
18
24
|
on_project { run_command("hound rules update ruby --local") }
|
19
25
|
end
|
@@ -22,7 +28,7 @@ module PotassiumTestHelpers
|
|
22
28
|
|
23
29
|
def drop_dummy_database
|
24
30
|
return unless File.exist?(project_path)
|
25
|
-
on_project { run_command("bundle exec
|
31
|
+
on_project { run_command("bundle exec rails db:drop") }
|
26
32
|
end
|
27
33
|
|
28
34
|
def add_fakes_to_path
|
@@ -51,25 +57,6 @@ module PotassiumTestHelpers
|
|
51
57
|
File.join(root_path, "bin", "potassium")
|
52
58
|
end
|
53
59
|
|
54
|
-
def default_arguments
|
55
|
-
{
|
56
|
-
"db" => "postgresql",
|
57
|
-
"locale" => "es-CL",
|
58
|
-
"heroku" => false,
|
59
|
-
"admin" => false,
|
60
|
-
"pundit" => false,
|
61
|
-
"paperclip" => false,
|
62
|
-
"email_service" => "aws_ses",
|
63
|
-
"devise" => false,
|
64
|
-
"api" => false,
|
65
|
-
"delayed-job" => false,
|
66
|
-
"github" => false,
|
67
|
-
"github-private" => false,
|
68
|
-
"clockwork" => false,
|
69
|
-
"sentry" => false
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
60
|
def hash_to_arguments(hash)
|
74
61
|
hash.map do |key, value|
|
75
62
|
if value == true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: potassium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 5.0.2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 5.0.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: gli
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +169,7 @@ email:
|
|
169
169
|
- julioggonz@gmail.com
|
170
170
|
executables:
|
171
171
|
- potassium
|
172
|
+
- potassium_test
|
172
173
|
extensions: []
|
173
174
|
extra_rdoc_files: []
|
174
175
|
files:
|
@@ -182,6 +183,7 @@ files:
|
|
182
183
|
- README.md
|
183
184
|
- Rakefile
|
184
185
|
- bin/potassium
|
186
|
+
- bin/potassium_test
|
185
187
|
- circle.yml
|
186
188
|
- docs/CONTRIBUTING.md
|
187
189
|
- docs/DSL.md
|
@@ -203,6 +205,7 @@ files:
|
|
203
205
|
- lib/potassium/assets/active_admin/pundit_page_policy.rb
|
204
206
|
- lib/potassium/assets/api/api_error_concern.rb
|
205
207
|
- lib/potassium/assets/api/base_controller.rb
|
208
|
+
- lib/potassium/assets/api/draper_responder.rb
|
206
209
|
- lib/potassium/assets/api/responder.rb
|
207
210
|
- lib/potassium/assets/app/mailers/application_mailer.rb
|
208
211
|
- lib/potassium/assets/bin/cibuild.erb
|
@@ -231,6 +234,7 @@ files:
|
|
231
234
|
- lib/potassium/cli.rb
|
232
235
|
- lib/potassium/cli/commands/create.rb
|
233
236
|
- lib/potassium/cli/commands/install.rb
|
237
|
+
- lib/potassium/cli_options.rb
|
234
238
|
- lib/potassium/generators/application.rb
|
235
239
|
- lib/potassium/generators/recipe.rb
|
236
240
|
- lib/potassium/helpers/answer-helpers.rb
|
@@ -240,6 +244,7 @@ files:
|
|
240
244
|
- lib/potassium/helpers/gem-helpers.rb
|
241
245
|
- lib/potassium/helpers/info-helpers.rb
|
242
246
|
- lib/potassium/helpers/readme-helpers.rb
|
247
|
+
- lib/potassium/helpers/rubocop-helpers.rb
|
243
248
|
- lib/potassium/helpers/template-dsl.rb
|
244
249
|
- lib/potassium/helpers/template-helpers.rb
|
245
250
|
- lib/potassium/helpers/variable-helpers.rb
|
@@ -250,12 +255,14 @@ files:
|
|
250
255
|
- lib/potassium/recipes/annotate.rb
|
251
256
|
- lib/potassium/recipes/api.rb
|
252
257
|
- lib/potassium/recipes/aws_sdk.rb
|
258
|
+
- lib/potassium/recipes/better_errors.rb
|
253
259
|
- lib/potassium/recipes/bower.rb
|
254
260
|
- lib/potassium/recipes/ci.rb
|
255
261
|
- lib/potassium/recipes/cleanup.rb
|
256
262
|
- lib/potassium/recipes/database.rb
|
257
263
|
- lib/potassium/recipes/delayed_job.rb
|
258
264
|
- lib/potassium/recipes/devise.rb
|
265
|
+
- lib/potassium/recipes/draper.rb
|
259
266
|
- lib/potassium/recipes/editorconfig.rb
|
260
267
|
- lib/potassium/recipes/env.rb
|
261
268
|
- lib/potassium/recipes/error_reporting.rb
|
@@ -281,6 +288,7 @@ files:
|
|
281
288
|
- lib/potassium/template_finder.rb
|
282
289
|
- lib/potassium/templates/application.rb
|
283
290
|
- lib/potassium/templates/recipe.rb
|
291
|
+
- lib/potassium/test_cli.rb
|
284
292
|
- lib/potassium/text_spinner.rb
|
285
293
|
- lib/potassium/version.rb
|
286
294
|
- potassium.gemspec
|
@@ -288,6 +296,7 @@ files:
|
|
288
296
|
- spec/fakes/bin/hub
|
289
297
|
- spec/features/ci_spec.rb
|
290
298
|
- spec/features/clockwork_spec.rb
|
299
|
+
- spec/features/draper_spec.rb
|
291
300
|
- spec/features/error_reporting_spec.rb
|
292
301
|
- spec/features/github_spec.rb
|
293
302
|
- spec/features/heroku_spec.rb
|
@@ -326,6 +335,7 @@ test_files:
|
|
326
335
|
- spec/fakes/bin/hub
|
327
336
|
- spec/features/ci_spec.rb
|
328
337
|
- spec/features/clockwork_spec.rb
|
338
|
+
- spec/features/draper_spec.rb
|
329
339
|
- spec/features/error_reporting_spec.rb
|
330
340
|
- spec/features/github_spec.rb
|
331
341
|
- spec/features/heroku_spec.rb
|